This is the mail archive of the
mailing list for the glibc project.
[RFC][BZ #16159] Detecting that recursive mutex recursed.
- From: Ondrej Bilka <neleai at seznam dot cz>
- To: libc-alpha at sourceware dot org
- Date: Wed, 13 Nov 2013 14:46:08 +0100
- Subject: [RFC][BZ #16159] Detecting that recursive mutex recursed.
- Authentication-results: sourceware.org; auth=none
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. */