[RFC][BZ #16159] Detecting that recursive mutex recursed.
Ondrej Bilka
neleai@seznam.cz
Wed Nov 13 15:30:00 GMT 2013
Hi,
To fix bugs with malloc async safety I would need a following primitive
int ptrhead_mutex_lock_cnt(pthread_mutex_t *m, int *cnt);
Which works like pthread_mutex_lock except it returns a number of times lock was recursively locked.
This would allow us to detect that function was invoked in signal and provide safe workaround.
In case of malloc we cound fall back to allocating with mmap and filling header that it could be appropriately freed.
A code would lock like this:
if (pthread_mutex_lock_cnt(lock, &cnt)
{
if (cnt > 0)
{
void *ret = mmap (NULL,size, ...
/* XXX initialize header. */
return ret;
}
}
Comments?
More information about the Libc-alpha
mailing list