File 1636-erts-Fix-assert-in-erts_add_taint-for-static-NIFs.patch of Package erlang

From a14c94649539f00ca09a7cf71a13f2f23e5c44ca Mon Sep 17 00:00:00 2001
From: lexprfuncall <5360361+lexprfuncall@users.noreply.github.com>
Date: Wed, 15 Jan 2025 17:02:19 -0800
Subject: [PATCH] erts: Fix assert in erts_add_taint for static NIFs

Debug builds configured with static NIFs are currently not usable
since they abort during startup.  The abort is caused by a check in
erts_add_taint that makes sense once the runtime has started but might
not be meaningful before the runtime has been started, notably during
static NIF initialization.

This change adds an additional check that allows erts_add_taint to
proceed when called during runtime initialization.  With this check,
a debug with static NIFs can complete the startup process.
---
 erts/emulator/beam/erl_nif.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index 765b808d31..44f7dd9ea0 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -4162,7 +4162,8 @@ void erts_add_taint(Eterm mod_atom)
 #endif
     struct tainted_module_t *first, *t;
 
-    ERTS_LC_ASSERT(erts_lc_rwmtx_is_rwlocked(&erts_driver_list_lock)
+    ERTS_LC_ASSERT(!erts_initialized
+                   || erts_lc_rwmtx_is_rwlocked(&erts_driver_list_lock)
                    || erts_has_code_write_permission());
 
     first = (struct tainted_module_t*) erts_atomic_read_nob(&first_taint);
-- 
2.43.0

openSUSE Build Service is sponsored by