--- Begin Message ---
- To: Debian Bug Tracking System <submit@bugs.debian.org>
- Subject: libc6: deadlock in syslog() after fork
- From: Marc Donner <donner@dbd-breitband.de>
- Date: Mon, 03 Dec 2007 20:24:07 +0100
- Message-id: <20071203192407.6071.53767.reportbug@booboo01>
Package: libc6
Version: 2.5-7
Severity: important
the syslog() funktion seems sometimes to end in a deadlock, if a
multithreaded process, where are threads logging to syslog, at the
same time does a fork() and the child trys to log something to syslog.
the child process hangs in the syslog call. the gdb backtrace is:
#0 0xb7e46b64 in __pthread_sigsuspend (set=0xbf8b7b3c) at
../linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c:54
#1 0xb7e45728 in __pthread_wait_for_restart_signal (self=0x806c8c0) at
pthread.c:1224
#2 0xb7e47fe6 in __pthread_alt_lock (lock=0xb7e3bd5c, self=0x806c8c0)
at restart.h:34
#3 0xb7e451dc in *__GI___pthread_mutex_lock (mutex=0xb7e3bd4c) at
mutex.c:123
#4 0xb7d9f8d0 in __tz_convert (timer=0xbf8b7d20, use_localtime=1,
tp=0xbf8b7c98) at tzset.c:570
#5 0xb7d9e00d in __localtime_r (t=0xbf8b7d20, tp=0xbf8b7c98) at
localtime.c:33
#6 0xb7dd98c8 in *__GI_vsyslog (pri=6, fmt=0x8063bae "session:%d -1",
ap=0xbf8b7d58 "\034\003") at ../sysdeps/generic/syslog.c:197
#7 0xb7dd97f2 in *__GI_syslog (pri=6, fmt=0x8063bae "session:%d -1") at
../sysdeps/generic/syslog.c:127
it seems as if the mutex is locked before the fork and not unlocked in
the child.
-- System Information:
Debian Release: lenny/sid
APT prefers stable
APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18.3
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
-- no debconf information
--- End Message ---
--- Begin Message ---
- To: Damian Pietras <daper@daper.net>
- Cc: 454183-done@bugs.debian.org
- Subject: Re: Bug#454183: libc6: deadlock in syslog() after fork
- From: Aurelien Jarno <aurelien@aurel32.net>
- Date: Tue, 10 Nov 2009 15:11:41 +0100
- Message-id: <20091110141141.GA4766@hall.aurel32.net>
- In-reply-to: <20090603071005.GA18770@daper.net>
- References: <20090603071005.GA18770@daper.net>
On Wed, Jun 03, 2009 at 09:10:06AM +0200, Damian Pietras wrote:
> Hi,
>
> I've found this bug doing a research on a similar issue in my program
> and think it's worth to add some information.
>
> This is not a bug but a behaviour that conforms to the specification:
>
> http://www.opengroup.org/onlinepubs/009695399/functions/pthread_atfork.html
>
> In short: calling any function that is not async-safe (man 7 signal) in
> child process after fork() call in a multi-threaded program has
> undefined behaviour. The problem is with functions (own or system
> library functions) that uses mutexes internally to protect global
> resources. When you call fork at the moment when some mutexes are locked
> you end up with a child that has only one thread and global data that
> were modified in critical sections in other threads at the moment of fork()
> are inconsistent. Also, mutexes are unusable in the child.
>
> See the above pthread_atfork() description to find out more.
>
Thanks for the explanation, I guess this bug can be closed now.
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
--- End Message ---