[PATCH] malloc-standard: synchronize on fork

Mike Frysinger vapier at gentoo.org
Sun Mar 27 21:36:09 UTC 2011


2011/3/27 Timo Teräs <timo.teras at iki.fi>:
> On 03/27/2011 10:21 PM, Rich Felker wrote:
>> On Sat, Mar 26, 2011 at 08:28:04PM +0200, Timo Teräs wrote:
>>> Otherwise other threads can leave malloc state locked, and the child
>>> will hang indefinitely if it tries to malloc something.
>>
>> This change by itself breaks as much as it fixes, unless the mutex
>> implementation is reentrant and recursive. fork() is specified to be
>> async-signal-safe, which means it's legal for a signal handler to call
>> fork() while malloc() is being executed. With your patch, this will
>> hang the program.
>
> Doing fork from signal handler seems utterly stupid. That would need
> extra precautions to work properly, because the malloc code is not
> re-entrant.

stupid or not, if POSIX says it's required to be supported, then we
have to support it
-mike


More information about the uClibc mailing list