This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/4737] fork is not async-signal-safe
- From: "tom dot honermann at oracle dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 11 Nov 2008 22:03:04 -0000
- Subject: [Bug libc/4737] fork is not async-signal-safe
- References: <20070704013541.4737.nmiell@comcast.net>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From tom dot honermann at oracle dot com 2008-11-11 22:03 -------
Another solution for this issue would be to use error checked mutexes (ie,
PTHREAD_MUTEX_ERRORCHECK). However, glibc 2.3.4 doesn't seem to have a generic
infrastructure for supporting error checked mutexes as it does for recursive
mutexes (ie, __libc_lock_init vs __libc_lock_init_recursive - there is no
__libc_lock_init_error_checked or similar that I can find), so this approach
might require a more invasive change.
If error checked mutexes were used, then ptmalloc_lock_all could be modified
similarly to the code below. (This assumes mutex_lock would return the same
values as pthread_mutex_lock)
static void
ptmalloc_lock_all (void)
{
mstate ar_ptr;
int rc;
if(__malloc_initialized < 1)
return;
rc = mutex_lock(&list_lock);
if(rc != 0 && rc != EDEADLK) {
/* Error handling */
}
for(ar_ptr = &main_arena;;) {
rc = mutex_lock(&ar_ptr->mutex);
if(rc != 0 && rc != EDEADLK) {
/* Error handling */
}
ar_ptr = ar_ptr->next;
if(ar_ptr == &main_arena) break;
}
save_malloc_hook = __malloc_hook;
save_free_hook = __free_hook;
__malloc_hook = malloc_atfork;
__free_hook = free_atfork;
/* Only the current thread may perform malloc/free calls now. */
tsd_getspecific(arena_key, save_arena);
tsd_setspecific(arena_key, ATFORK_ARENA_PTR);
}
--
http://sourceware.org/bugzilla/show_bug.cgi?id=4737
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.