[Bug nptl/21031] pthread_key_delete() race with thread finalization

pobrn at protonmail dot com sourceware-bugzilla@sourceware.org
Mon Oct 21 18:10:04 GMT 2024


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

--- Comment #8 from Barnabás Pőcze <pobrn at protonmail dot com> ---
The core issue here is how one is expected to safely use
`pthread_key_delete()`. The current glibc and musl implementations do not
synchronize destructor calls caused by thread termination with calls to
`pthread_key_delete()`. This makes it possible for a destructor to be called in
a terminating thread after `pthread_key_delete()` returns. For this reason, it
is not feasible to delete the key, then iterate over a list of all thread local
objects to free the remaining ones because that might race with thread
termination and lead to double frees. So I am wondering what the expected usage
of `pthread_key_delete()` is, because to me this behaviour seems to be a
significant oversight in the current design, unless I am (hopefully) missing
something.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Glibc-bugs mailing list