Bug 494337

Summary: All threaded applications cause still holding lock errors
Product: [Developer tools] valgrind Reporter: Paul Floyd <pjfloyd>
Component: helgrindAssignee: Paul Floyd <pjfloyd>
Status: RESOLVED FIXED    
Severity: major    
Priority: NOR    
Version First Reported In: 3.24 GIT   
Target Milestone: ---   
Platform: Other   
OS: FreeBSD   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Paul Floyd 2024-10-09 08:57:12 UTC
Due to this POSIX issue

https://austingroupbugs.net/view.php?id=1845

FreeBSD libc now deliberately leaks a locked pthread_mutex to protect exit()

https://github.com/freebsd/freebsd-src/commit/3f3ec4b99f79d32a0bf15495559ca9883bd751f2

musl libc may do something similar
https://elixir.bootlin.com/musl/v1.2.5/source/src/exit/exit.c#L27
It uses some internal locking mechanism for some things but also a mutex and rwlock in __libc_exit_fini.

No idea about other libc implementations for the moment.
Comment 1 Paul Floyd 2024-10-09 09:07:50 UTC
It looks like glibc uses an intenral locking mechanism.

https://sourceware.org/bugzilla/show_bug.cgi?id=31997

and

https://sourceware.org/pipermail/libc-alpha/2024-July/158579.html
Comment 2 Paul Floyd 2024-10-12 14:06:49 UTC
I've pushed a change that turns off this check for FreeBSD 15 and later.

I don't consider that to be a definitive fix so I'm not closing this item.
Comment 3 Paul Floyd 2024-11-03 18:49:51 UTC
commit 5c47ad94a0485cccd2a41506dd7e83f58b4569c3 (HEAD -> master, origin/master, origin/HEAD)
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Sun Nov 3 19:47:12 2024 +0100

    Bug 494337 - All threaded applications cause still holding lock errors
    
    Don't count the first call to pthread_mutex_lock() from exit().
    
    Needed to update a couple of expecteds as exit() is now wrapped
    so it turns up in the callstacks.
    
    This is only for FreeBSD.