Page MenuHomeFreeBSD

libthr: allow very early atfork registration
AcceptedPublic

Authored by kevans on Thu, Oct 31, 4:20 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 4, 11:09 PM
Unknown Object (File)
Fri, Nov 1, 4:04 AM
Unknown Object (File)
Fri, Nov 1, 4:03 AM
Unknown Object (File)
Fri, Nov 1, 4:03 AM
Unknown Object (File)
Fri, Nov 1, 3:36 AM
Subscribers

Details

Reviewers
kib
markj
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 60287
Build 57171: arc lint + arc unit

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.Thu, Oct 31, 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.Thu, Oct 31, 4:40 PM
This revision is now accepted and ready to land.Thu, Oct 31, 5:21 PM