Page MenuHomeFreeBSD

libthr: allow very early atfork registration
ClosedPublic

Authored by kevans on Oct 31 2024, 4:20 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 11, 3:21 AM
Unknown Object (File)
Tue, Dec 3, 1:16 PM
Unknown Object (File)
Sat, Nov 30, 2:04 PM
Unknown Object (File)
Nov 24 2024, 8:10 AM
Unknown Object (File)
Nov 24 2024, 2:45 AM
Unknown Object (File)
Nov 21 2024, 7:21 PM
Unknown Object (File)
Nov 14 2024, 3:12 AM
Unknown Object (File)
Nov 9 2024, 6:34 PM
Subscribers

Details

Summary

LSan wants to be able to register atfork handlers at __lsan_init time,
which can happen either at the first intercepted function call or in a
.preinit_array function. Both of these end up being very early in rtld
and executed with the bind lock held, which ends up causing problems
when we go to _libpthread_init().

Instead of requiring libpthread to be initialized, just insert the new
atfork handler straight into the list if it's not ready yet. The
critical section and locking should not be necessary if we're really
executing this early, as there won't be any threads to contend with.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

lib/libthr/thread/thr_init.c
522

So do we need at least a formal static initializer for the _thr_atfork_list?

lib/libthr/thread/thr_init.c
522

It seems to have already had one for years

This revision is now accepted and ready to land.Oct 31 2024, 10:38 AM
markj added inline comments.
lib/libthr/tests/atfork_test.c
50

Please add a brief comment describing what the test is doing.

Add some comments and a short description for the test listing.

This revision now requires review to proceed.Oct 31 2024, 4:40 PM
This revision is now accepted and ready to land.Oct 31 2024, 5:21 PM
This revision was automatically updated to reflect the committed changes.