From de2e817ba7a531bd894b8ddb407dc9dd57b46515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= Date: Wed, 7 Feb 2024 17:58:11 +0100 Subject: [PATCH 1/3] erts: Fix stopping 'long_timers_test' of other versions If the long timers test lingers in the background during tests, and can even persist after tests have been aborted. To deal with this, the test tries to stop previous nodes, but does so with a local fun which fails if the OTP version has changed in the meantime, for example if rebasing something to an earlier version. To fix this, we'll use an external fun instead so that we'll be capable of stopping nodes of any version from here on. --- erts/emulator/test/long_timers_test.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erts/emulator/test/long_timers_test.erl b/erts/emulator/test/long_timers_test.erl index de1a6e6d322f..899818fe2a6a 100644 --- a/erts/emulator/test/long_timers_test.erl +++ b/erts/emulator/test/long_timers_test.erl @@ -462,7 +462,7 @@ start_node(Name) -> stop_node(Node) -> monitor_node(Node, true), - spawn(Node, fun () -> halt() end), + spawn(Node, fun erlang:halt/0), receive {nodedown, Node} -> ok end. load_driver(Dir, Driver) -> From b8989bfabc3949adc228c1c892e04bbd59cc13db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= Date: Wed, 7 Feb 2024 15:39:26 +0100 Subject: [PATCH 2/3] jit: Add missing updates in emit_process_exit --- erts/emulator/beam/jit/arm/beam_asm_global.cpp | 4 ++-- erts/emulator/beam/jit/x86/beam_asm_global.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/erts/emulator/beam/jit/arm/beam_asm_global.cpp b/erts/emulator/beam/jit/arm/beam_asm_global.cpp index 5e4360a7708c..d0891607251f 100644 --- a/erts/emulator/beam/jit/arm/beam_asm_global.cpp +++ b/erts/emulator/beam/jit/arm/beam_asm_global.cpp @@ -265,7 +265,7 @@ void BeamModuleAssembler::emit_raise_exception(Label I, } void BeamGlobalAssembler::emit_process_exit() { - emit_enter_runtime(); + emit_enter_runtime(); a.mov(ARG1, c_p); mov_imm(ARG2, 0); @@ -273,7 +273,7 @@ void BeamGlobalAssembler::emit_process_exit() { load_x_reg_array(ARG3); runtime_call<4>(handle_error); - emit_leave_runtime(); + emit_leave_runtime(); a.cbz(ARG1, labels[do_schedule]); a.udf(0xdead); diff --git a/erts/emulator/beam/jit/x86/beam_asm_global.cpp b/erts/emulator/beam/jit/x86/beam_asm_global.cpp index ec38e05323c5..f15995efe3a4 100644 --- a/erts/emulator/beam/jit/x86/beam_asm_global.cpp +++ b/erts/emulator/beam/jit/x86/beam_asm_global.cpp @@ -278,7 +278,7 @@ void BeamModuleAssembler::emit_raise_exception(x86::Gp I, } void BeamGlobalAssembler::emit_process_exit() { - emit_enter_runtime(); + emit_enter_runtime(); a.mov(ARG1, c_p); mov_imm(ARG2, 0); @@ -286,7 +286,7 @@ void BeamGlobalAssembler::emit_process_exit() { load_x_reg_array(ARG3); runtime_call<4>(handle_error); - emit_leave_runtime(); + emit_leave_runtime(); a.test(RET, RET); a.je(labels[do_schedule]); From 59696d50538e7168d77c1374c64e9016e54a4896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= Date: Wed, 7 Feb 2024 14:19:25 +0100 Subject: [PATCH 3/3] jit: Add debug code in emit_enter_runtime to catch missing updates --- erts/emulator/beam/jit/arm/beam_asm.hpp | 22 ++++++++++++++++++---- erts/emulator/beam/jit/x86/beam_asm.hpp | 24 ++++++++++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/erts/emulator/beam/jit/arm/beam_asm.hpp b/erts/emulator/beam/jit/arm/beam_asm.hpp index 8ef609f4b2aa..8fc8a7b41130 100644 --- a/erts/emulator/beam/jit/arm/beam_asm.hpp +++ b/erts/emulator/beam/jit/arm/beam_asm.hpp @@ -461,10 +461,24 @@ struct BeamAssembler : public BeamAssemblerCommon { /* Store HTOP and E in one go. */ ERTS_CT_ASSERT_FIELD_PAIR(Process, htop, stop); a.stp(HTOP, E, arm::Mem(c_p, offsetof(Process, htop))); - } else if (Spec & Update::eStack) { - a.str(E, arm::Mem(c_p, offsetof(Process, stop))); - } else if (Spec & Update::eHeap) { - a.str(HTOP, arm::Mem(c_p, offsetof(Process, htop))); + } else { + if (Spec & Update::eStack) { + a.str(E, arm::Mem(c_p, offsetof(Process, stop))); + } else { +#ifdef DEBUG + /* Store some garbage in the process structure to catch missing + * updates. */ + a.str(active_code_ix, arm::Mem(c_p, offsetof(Process, stop))); +#endif + } + + if (Spec & Update::eHeap) { + a.str(HTOP, arm::Mem(c_p, offsetof(Process, htop))); + } else { +#ifdef DEBUG + a.str(active_code_ix, arm::Mem(c_p, offsetof(Process, htop))); +#endif + } } if (Spec & Update::eReductions) { diff --git a/erts/emulator/beam/jit/x86/beam_asm.hpp b/erts/emulator/beam/jit/x86/beam_asm.hpp index c7f085ee622e..585ada4d596f 100644 --- a/erts/emulator/beam/jit/x86/beam_asm.hpp +++ b/erts/emulator/beam/jit/x86/beam_asm.hpp @@ -645,10 +645,26 @@ struct BeamAssembler : public BeamAssemblerCommon { a.movups(x86::xmmword_ptr(c_p, offsetof(Process, htop)), x86::xmm0); } - } else if (Spec & Update::eHeap) { - a.mov(x86::qword_ptr(c_p, offsetof(Process, htop)), HTOP); - } else if (Spec & Update::eStack) { - a.mov(x86::qword_ptr(c_p, offsetof(Process, stop)), E); + } else { + if (Spec & Update::eHeap) { + a.mov(x86::qword_ptr(c_p, offsetof(Process, htop)), HTOP); + } else { +#ifdef DEBUG + /* Store some garbage in the process structure to catch + * missing updates. */ + a.mov(x86::qword_ptr(c_p, offsetof(Process, htop)), + active_code_ix); +#endif + } + + if (Spec & Update::eStack) { + a.mov(x86::qword_ptr(c_p, offsetof(Process, stop)), E); + } else { +#ifdef DEBUG + a.mov(x86::qword_ptr(c_p, offsetof(Process, stop)), + active_code_ix); +#endif + } } #ifdef NATIVE_ERLANG_STACK