File 0935-erts-Fix-racy-assert-in-erts_fire_nif_monitor.patch of Package erlang

From b2227169a5d6ebcb980a1bc64081bdaf87ae367a Mon Sep 17 00:00:00 2001
From: Sverker Eriksson <sverker@erlang.org>
Date: Mon, 10 Aug 2020 13:31:57 +0200
Subject: [PATCH] erts: Fix racy assert in erts_fire_nif_monitor

If is_dying then the resource may be deallocated
by other thread after we release the lock.
---
 erts/emulator/beam/erl_nif.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index 9b12c459fe..83bed11164 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -2706,9 +2706,10 @@ void erts_fire_nif_monitor(ErtsMonitor *tmon)
     erts_mtx_unlock(&rmp->lock);
 
     if (!active) {
-        ASSERT(!is_dying || erts_refc_read(&bin->binary.intern.refc, 0) == 0);
-        if (is_dying && mrefc == 0)
+        if (is_dying && mrefc == 0) {
+            ASSERT(erts_refc_read(&bin->binary.intern.refc, 0) == 0);
             erts_bin_free(&bin->binary);
+        }
         erts_monitor_release(tmon);
     }
     else {
-- 
2.26.2

openSUSE Build Service is sponsored by