File 0860-erts-Try-fix-race-in-erlang-halt.patch of Package erlang
From c06699062f700a5c245e1998f7cff88268f53b70 Mon Sep 17 00:00:00 2001
From: Sverker Eriksson <sverker@erlang.org>
Date: Wed, 3 Jul 2024 16:24:07 +0200
Subject: [PATCH] erts: Try fix race in erlang:halt
If two or more processes calls halt it seems the yielded
dummy call halt(undefined,undefined) can actually happen.
Suspend the calling process to make sure it does get scheduled again.
---
erts/emulator/beam/bif.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c
index 8c50be31f3..592137d6bd 100644
--- a/erts/emulator/beam/bif.c
+++ b/erts/emulator/beam/bif.c
@@ -4304,6 +4304,10 @@ BIF_RETTYPE halt_2(BIF_ALIST_2)
("System halted by BIF halt(%T, %T)\n", BIF_ARG_1, BIF_ARG_2));
if (flush) {
erts_halt(pos_int_code);
+ /* We lost race against other halt call.
+ Suspend this process and do a dummy trap while waiting
+ for other halt call to terminate the beam. */
+ erts_suspend(BIF_P, ERTS_PROC_LOCK_MAIN, NULL);
ERTS_BIF_YIELD2(BIF_TRAP_EXPORT(BIF_halt_2), BIF_P, am_undefined, am_undefined);
}
else {
--
2.43.0