From: Paul Floyd Date: Sun, 7 Dec 2025 06:54:23 +0000 (+0100) Subject: Darwin stacktraces: add a hack to prevent segfault when dereferencing bp X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55129845cd0e2a8415b945953a035265b417afaf;p=thirdparty%2Fvalgrind.git Darwin stacktraces: add a hack to prevent segfault when dereferencing bp 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. --- diff --git a/coregrind/m_stacktrace.c b/coregrind/m_stacktrace.c index fa2dc0964..5175f79fe 100644 --- a/coregrind/m_stacktrace.c +++ b/coregrind/m_stacktrace.c @@ -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; diff --git a/helgrind/tests/shared_timed_mutex.vgtest b/helgrind/tests/shared_timed_mutex.vgtest index 8903894e6..d3a044379 100644 --- a/helgrind/tests/shared_timed_mutex.vgtest +++ b/helgrind/tests/shared_timed_mutex.vgtest @@ -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 diff --git a/helgrind/tests/tc22_exit_w_lock.vgtest b/helgrind/tests/tc22_exit_w_lock.vgtest index 8dd7531ec..2e6190a72 100644 --- a/helgrind/tests/tc22_exit_w_lock.vgtest +++ b/helgrind/tests/tc22_exit_w_lock.vgtest @@ -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.*