File 6033-erts-Silence-valgrind-about-uninitialized-data-in-st.patch of Package erlang

From bf8690a3038e7bc1c6f0180aa63c9240ae05d0fb Mon Sep 17 00:00:00 2001
From: Sverker Eriksson <sverker@erlang.org>
Date: Wed, 23 Oct 2024 19:41:59 +0200
Subject: [PATCH 3/3] erts: Silence valgrind about uninitialized data in
 stacktrace bignum

when printed to crash dump.
---
 erts/emulator/beam/beam_common.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/erts/emulator/beam/beam_common.c b/erts/emulator/beam/beam_common.c
index cdcbb6d8dd..4d3af9e944 100644
--- a/erts/emulator/beam/beam_common.c
+++ b/erts/emulator/beam/beam_common.c
@@ -35,6 +35,9 @@
 #include "beam_catches.h"
 #include "beam_common.h"
 #include "erl_global_literals.h"
+#ifdef VALGRIND
+#  include <valgrind/memcheck.h>
+#endif
 
 #ifdef USE_VM_PROBES
 #include "dtrace-wrapper.h"
@@ -1044,6 +1047,17 @@ save_stacktrace(Process* c_p, ErtsCodePtr pc, Eterm* reg,
 
     /* Save the actual stack trace */
     gather_stacktrace(c_p, s);
+
+#ifdef VALGRIND
+    /* Make sure entire bignum is defined in case it shows up in a crash dump */
+    {
+        const int words_left = s->max_depth - s->depth;
+        if (words_left) {
+            VALGRIND_MAKE_MEM_DEFINED(&s->trace[s->depth],
+                                      words_left * sizeof(ErtsCodePtr));
+        }
+    }
+#endif
 }
 
 void
-- 
2.43.0

openSUSE Build Service is sponsored by