From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11070 invoked by alias); 11 Nov 2008 22:04:17 -0000 Received: (qmail 31615 invoked by uid 48); 11 Nov 2008 22:03:04 -0000 Date: Tue, 11 Nov 2008 22:04:00 -0000 Message-ID: <20081111220304.31614.qmail@sourceware.org> From: "tom dot honermann at oracle dot com" To: glibc-bugs@sources.redhat.com In-Reply-To: <20070704013541.4737.nmiell@comcast.net> References: <20070704013541.4737.nmiell@comcast.net> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug libc/4737] fork is not async-signal-safe X-Bugzilla-Reason: CC Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2008-11/txt/msg00039.txt.bz2 ------- 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.