[PATCH] malloc-standard: synchronize on fork

Rich Felker dalias at aerifal.cx
Mon Mar 28 22:06:45 UTC 2011


On Mon, Mar 28, 2011 at 11:43:00PM +0300, Timo Teräs wrote:
> >> It is recursive mutex. It's works perfectly fine if same thread locks
> >> that mutex multiple times.
> > 
> > But not from a signal handler. There's almost surely a race between
> > locking the mutex and having it in the right state so that the signal
> > handler sees it's the owner.
> 
> Oh. That's right. There's a race for that. I've been trying to figure
> how glibc handles that, but it'd seem that it does not. Hmmh.
> 
> Not sure what to do here. Need to think about it. Any great ideas?

You could enhance the recursive mutex implementation to be reentrant -
having a single atomic int that serves as both the lock status and the
owner and updating it with an atomic compare-and-swap should be one
way to do this.


Rich


More information about the uClibc mailing list