File 2891-erts-Assert-that-GC-should-not-be-disabled-twice.patch of Package erlang
From 2571cbf025e164989e15502da57de4d5e339f07d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org>
Date: Fri, 3 May 2019 09:54:15 +0200
Subject: [PATCH 1/3] erts: Assert that GC should not be disabled twice
---
erts/emulator/beam/erl_process.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c
index 1f6adb98ef..e69a9b8813 100644
--- a/erts/emulator/beam/erl_process.c
+++ b/erts/emulator/beam/erl_process.c
@@ -12035,8 +12035,13 @@ erts_set_gc_state(Process *c_p, int enable)
ERTS_SMP_LC_ASSERT(ERTS_PROC_LOCK_MAIN == erts_proc_lc_my_proc_locks(c_p));
if (!enable) {
- c_p->flags |= F_DISABLE_GC;
- return 0;
+ /* Strictly speaking it's not illegal to disable the GC when it's
+ * already disabled, but we risk enabling the GC prematurely if (for
+ * example) a BIF were to blindly disable it when trapping and then
+ * re-enable it before returning its result. */
+ ASSERT(!(c_p->flags & F_DISABLE_GC));
+ c_p->flags |= F_DISABLE_GC;
+ return 0;
}
c_p->flags &= ~F_DISABLE_GC;
--
2.16.4