[Bug 2341] New: Forked new process with locked malloc mutex
bugzilla at busybox.net
bugzilla at busybox.net
Thu Aug 5 13:17:59 UTC 2010
https://bugs.busybox.net/show_bug.cgi?id=2341
Summary: Forked new process with locked malloc mutex
Product: uClibc
Version: 0.9.32
Platform: PC
OS/Version: Linux
Status: NEW
Severity: critical
Priority: P5
Component: Threads
AssignedTo: unassigned at uclibc.org
ReportedBy: s_v_d_2000 at mail.ru
CC: uclibc-cvs at uclibc.org
Estimated Hours: 0.0
Created attachment 2293
--> https://bugs.busybox.net/attachment.cgi?id=2293
Patch for relocking malloc mutex in libc_fork
Happens in multithreading applications. If one thread going to fork while
another thread works with memory (call malloc, free etc) then in new process we
have locked malloc mutex (libc/stdlib/malloc-standart/malloc.c: __malloc_lock).
In linuxthreads.old, in ptfork.c all malloc mutexes (depends on malloc
subsystem type) locked before fork and unlocked after. In glibc used code like
next:
static void
ptmalloc_lock_all (void)
{
...
__pthread_mutex_lock(&__malloc_lock);
...
}
static void
ptmalloc_unlock_all (void)
{
...
__pthread_mutex_unlock(&__malloc_lock);
...
}
static void
ptmalloc_unlock_all2 (void)
{
...
__pthread_mutex_init(__malloc_lock, ...);
...
}
void
ptmalloc_init (void) {
...
__pthread_atfork(ptmalloc_lock_all, ptmalloc_unlock_all,
ptmalloc_unlock_all2);
...
}
But in my system (x86_64) using pthread_atfork cause segmentation fault.
So i modify libc_fork function directly (patch attached).
P.S.: It possible several another mutexes incorrectly forked. Need to check.
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the uClibc-cvs
mailing list