Invoke _rtld_atfork_post earlier, before we reinitialize rtld locks

by switching into single-thread mode.

libthr ignores broken use of lock bitmaps used by default rtld locking
implementation, this in turn turns lock handoff in _rtld_thread_init
into NOP. This in turn makes child processes of forked multi-threaded
programs to run with _thr_signal_block still in effect, with most
signals blocked.

Reported by: phk, kib
This commit is contained in:
Alexander Kabaev 2008-12-01 21:00:25 +00:00
parent 92bf0e27a0
commit 97df383415
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=185531

View File

@ -158,6 +158,9 @@ _fork(void)
/* clear other threads locked us. */
_thr_umutex_init(&curthread->lock);
_thr_umutex_init(&_thr_atfork_lock);
if (unlock_malloc)
_rtld_atfork_post(rtld_locks);
_thr_setthreaded(0);
/* reinitialize libc spinlocks. */
@ -170,10 +173,8 @@ _fork(void)
/* Ready to continue, unblock signals. */
_thr_signal_unblock(curthread);
if (unlock_malloc) {
_rtld_atfork_post(rtld_locks);
if (unlock_malloc)
_malloc_postfork();
}
/* Run down atfork child handlers. */
TAILQ_FOREACH(af, &_thr_atfork_list, qe) {