threads/76690: fork hang in child for (-lc_r & -lthr)

Sven Berkvens-Matthijsse sven at ilse.net
Mon Oct 24 07:00:37 PDT 2005


> I'm not interested in maintaining libc_r, but I looked at the fix.
> It exports symbols into the application namespace (those without
> leading underscores).

It does (which I can fix if you'd like). The reason is that I only
changed the names of those mutexes and spinlocks that were called
"thread_lock". I'm lazy, I know :-)

> It also looks to me like an application bug since you can only use
> async signal safe functions in the child after a fork() from a
> threaded application and before an exec() of some sort.

That's correct, but the libc_r library calls free() itself to clean up 
after all threads other than the current one (which according to the
specs don't exist in a forked program). So it's a bug in the library,
I guess, because it calls non-async-signal-safe functions itself.
See /usr/src/lib/libc_r/uthread/uthread_fork.c, in which the freeing
happens.

> -- 
> DE

-- 
Sven


More information about the freebsd-threads mailing list