]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
FreeBSD helgrind: temporary (?) fix for Bug 494337
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 12 Oct 2024 07:10:21 +0000 (09:10 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 12 Oct 2024 07:10:21 +0000 (09:10 +0200)
FreeBSD 15 has added a pthread lock to exit() to ensure that atexit handling
is thread safe. Unfortunately that lock gets leaked which messes up just about
all of the Helgrind tests.

Supression won't work as the callstack is the same for both genuine leaks
and this deliberate leak.

This change simply turns off the check for FreeBSD >= 15.

I see two possible proper fixes. One would be to allow one lock on exit.
The problem with that is that we will need to tell apart a clean exit
(1 lock allowed) and any kind of abort that doesn't call exit (no locks
allowed). That's going to be tricky as the Helgrind check is done before
we get back to core and know whether it is an abort or a clean exit.

The other thing would be to hack the lock counting. If we can detect that
it's a pthread_mutex_lock called from exit() then we could ignore that for
counting purposes. That would mean a possibly significant overhead for
each call to pthread_mutex_lock on FreeBSD.

helgrind/hg_main.c
helgrind/tests/Makefile.am

index bf1af3b4af5ba9be53cc06835a5c76881fdd0fba..8522b593f95f17e0dd3605e5cff50083e7eafa66 100644 (file)
@@ -1716,12 +1716,14 @@ void evh__pre_thread_ll_exit ( ThreadId quit_tid )
    /* Complain if this thread holds any locks. */
    nHeld = HG_(cardinalityWS)( univ_lsets, thr_q->locksetA );
    tl_assert(nHeld >= 0);
+#if !defined(VGO_freebsd) || (FREEBSD_VERS < FREEBSD_15)
    if (nHeld > 0) {
       HChar buf[80];
       VG_(sprintf)(buf, "Exiting thread still holds %d lock%s",
                         nHeld, nHeld > 1 ? "s" : "");
       HG_(record_error_Misc)( thr_q, buf );
    }
+#endif
 
    /* Not much to do here:
       - tell libhb the thread is gone
index 0f2a5ef8580d93f1da5ffff9dae936c02b52e881..d7101ed1aa2e286c7aaf15ba0f1d6e6189f85a32 100755 (executable)
@@ -87,6 +87,7 @@ EXTRA_DIST = \
                tc03_re_excl.stderr.exp \
        tc04_free_lock.vgtest tc04_free_lock.stdout.exp \
                tc04_free_lock.stderr.exp \
+               tc04_free_lock.stderr.exp-freebsd15 \
        tc05_simple_race.vgtest tc05_simple_race.stdout.exp \
                tc05_simple_race.stderr.exp \
        tc06_two_races.vgtest tc06_two_races.stdout.exp \
@@ -99,6 +100,7 @@ EXTRA_DIST = \
        tc09_bad_unlock.vgtest tc09_bad_unlock.stdout.exp \
                tc09_bad_unlock.stderr.exp tc09_bad_unlock.stderr.exp-solaris \
                tc09_bad_unlock.stderr.exp-freebsd \
+               tc09_bad_unlock.stderr.exp-freebsd15 \
        tc10_rec_lock.vgtest tc10_rec_lock.stdout.exp tc10_rec_lock.stderr.exp \
        tc11_XCHG.vgtest tc11_XCHG.stdout.exp tc11_XCHG.stderr.exp \
        tc12_rwl_trivial.vgtest tc12_rwl_trivial.stdout.exp \
@@ -137,6 +139,7 @@ EXTRA_DIST = \
                tc22_exit_w_lock.stderr.exp \
                tc22_exit_w_lock.stderr.exp-kfail-x86 \
                tc22_exit_w_lock.stderr.exp-solaris \
+               tc22_exit_w_lock.stderr.exp-freebsd15 \
        tc23_bogus_condwait.vgtest tc23_bogus_condwait.stdout.exp \
                tc23_bogus_condwait.stderr.exp \
                tc23_bogus_condwait.stderr.exp-mips32 \