]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Darwin stacktraces: add a hack to prevent segfault when dereferencing bp
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 7 Dec 2025 06:54:23 +0000 (07:54 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 7 Dec 2025 06:54:23 +0000 (07:54 +0100)
Can now turn a couple more helgrind tests back on.
Need to get to the bottom of the bp dereferencing issue. There is a test
already so it us supposed to be safe.

coregrind/m_stacktrace.c
helgrind/tests/shared_timed_mutex.vgtest
helgrind/tests/tc22_exit_w_lock.vgtest

index fa2dc096443b1a7fc52c2cf5fb0b5ac14949c0f1..5175f79fef984f58d4bc1e05af929fe601ebad90 100644 (file)
@@ -691,7 +691,20 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
          fact that we are prodding at & ((UWord*)fp)[1] and so need to
          adjust the limit check accordingly.  Omitting this has been
          observed to cause segfaults on rare occasions. */
-      if (fp_min <= uregs.xbp && uregs.xbp <= fp_max - 1 * sizeof(UWord)) {
+      if (fp_min <= uregs.xbp && uregs.xbp <= fp_max - 1 * sizeof(UWord)
+#if defined(VGO_darwin)
+          // FIXME PJF temporary? workaround for segfaults
+          // without this extra check there will be some SIGSEGVs which end stuck
+          // in an infinite loop
+
+          // The faulting address seems to be in a fairly small rw- mapping
+          // (according to lldb)
+          // happens in Helgrind multithread apps, error arises in
+          // sync_signalhandler (called from darwin_signal_demux with signal 11)
+
+          && ML_(safe_to_deref)((void*)uregs.xbp, 2*sizeof(UWord))
+#endif
+                                                                        ) {
          /* fp looks sane, so use it. */
          uregs.xip = (((UWord*)uregs.xbp)[1]);
          if (0 == uregs.xip || 1 == uregs.xip) break;
index 8903894e6aad5ac63daab65ad1fa07ed051e7b00..d3a044379c860e7a76ecbe094dd5d83da2cb38ac 100644 (file)
@@ -1,3 +1,3 @@
-prereq: test -e ../../drd/tests/shared_timed_mutex && ! ../../tests/os_test darwin
+prereq: test -e ../../drd/tests/shared_timed_mutex
 vgopts: --read-var-info=yes
 prog: ../../drd/tests/shared_timed_mutex
index 8dd7531ec5fb85ecb48bc328fa366485377281f5..2e6190a727c2c7f8cbb98377f3d633a58b211a3a 100644 (file)
@@ -1,3 +1,3 @@
-prereq: test -e tc22_exit_w_lock && ! ../../tests/os_test darwin
+prereq: test -e tc22_exit_w_lock
 prog: tc22_exit_w_lock
 cleanup: rm -f vgcore.*