threaded, forked, rethreaded processes will deadlock
David Schultz
das at FreeBSD.ORG
Wed Jan 21 23:42:58 PST 2009
On Thu, Jan 22, 2009, David Schultz wrote:
> If you can't implement functions that are required to be
> async-signal-safe like fork() and exec() without malloc(), then
> for now I guess we should go for something along the lines of what
> Brian is proposing. If the app programmer has taken special pains
> to ensure that all other threads are stopped when a fork happens,
> the fork() call shouldn't return in the child with all the malloc
> locks bogusly held.
Note that even with Brian's patch, the memory associated with the
all the parent's threads' stacks is leaked, and libthr can't be
expected to be in a particularly happy state after all of its
threads disappear. It just happens to (sort of) work for now.
In any case, it's clearly a bug that libthr's fork handler calls
_malloc_postfork() in the child even when _malloc_postfork()
doesn't work properly in the (now single-threaded) child. Which
way to fix it is up to you guys...
More information about the freebsd-hackers
mailing list