RFC: Deadlock in multithreaded application when doing IO and fork.
Florian Weimer
fweimer@redhat.com
Thu Apr 14 08:11:00 GMT 2016
On 02/01/2013 12:02 AM, Carlos O'Donell wrote:
> another thread could be inside malloc and trigger an
> assertion or debug output, which will block, and
> deadlock fork() e.g.
>
> T1 T2
> fork
> take list_all_lock
> calls malloc
> takes arena lock.
> malloc aborts and tries to do IO.
> or
> user define malloc tries to do IO.
> blocks on list_all_lock.
> blocks on arena lock
The bug discussed in this old thread is now fixed on master, with commit
29d794863cd6e03115d3670707cc873a9965ba92.
IMO, the deadlock you describe is not relevant because list_all_lock is
only taken on fflush (NULL) or if a stdio stream is opened or closed.
abort does not flush the streams under list_all_lock (ugh). Opening or
closing a stdio stream performs malloc or free, so it will potentially
deadlock even without the presence of list_all_lock, just involving the
malloc locks. A malloc calling into stdio is just undefined. We get
away with it to some extent because we implement both, but an interposed
malloc cannot do this.
Florian
More information about the Libc-alpha
mailing list