This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: malloc/free is signal-safe?


The backtrace I posted was the deadlock on the main thread. I forgot to mention that I had a ton of secondary threads stuck on a different lock in free(), it's probably an after-effect of the deadlock:

Thread 2 (Thread 0x7f89dedad700 (LWP 6565)):
#0  __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:93
#1  0x00007f8a2a702fb6 in _L_lock_3578 () at malloc.c:5220
#2  0x00007f8a2a6fd98b in _int_free (av=0x7f8a2aa36720, p=0x1d30540, have_lock=0) at malloc.c:4042
#3  0x000000000040ca61 in HandleConnection (conn=0x1d30550) at server.c:410
#4  0x00007f8a2aa44e9a in start_thread (arg=0x7f89dedad700) at pthread_create.c:308
#5  0x00007f8a2a771ccd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#6  0x0000000000000000 in ?? ()


Dimitris

On Tue, 4 Jun 2013, Dimitrios Apostolou wrote:

Hello list,

according to the libc manual, malloc is signal-safe in glibc. However I got a deadlock when I sigTERM'd a process during malloc(), and it tried to log with vasprintf() (which itself calls malloc).

Am I missing something regarding libc's malloc() reentrancy? Here is the backtrace I got:


Thread 1 (Thread 0x7f8a2b5d7700 (LWP 129400)):
#0 __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:93
#1  0x00007f8a2a703231 in _L_lock_10655 () at malloc.c:5220
#2 0x00007f8a2a700fb7 in __GI___libc_malloc (bytes=140231397566240) at malloc.c:2921 #3 0x00007f8a2a788156 in __GI___vasprintf_chk (result_ptr=0x7fff02f50ac8, flags=1, format=0x7f8a2b15a248 "Received signal %d (%s) while doing [%s]", args=0x7fff02f50b18) at vasprintf_chk.c:50 #4 0x00007f8a2b08af91 in vasprintf (__ap=<optimized out>, __fmt=<optimized out>, __ptr=0x7fff02f50ac8) at /usr/include/x86_64-linux-gnu/bits/stdio2.h:199 #5 xvasprintf (strp=<optimized out>, fmt=<optimized out>, ap=<optimized out>) at alloc.c:83 #6 0x00007f8a2b08ca24 in StringVFormat (fmt=<optimized out>, ap=<optimized out>) at string_lib.c:796 #7 0x00007f8a2b08f8d3 in VLog (level=LOG_LEVEL_ERR, fmt=0x7f8a2b15a248 "Received signal %d (%s) while doing [%s]", ap=0x7fff02f50b18) at logging.c:183 #8 0x00007f8a2b08f9c7 in Log (level=<optimized out>, fmt=<optimized out>) at logging.c:211
#9  0x00007f8a2b07defb in HandleSignalsForDaemon (signum=15) at signals.c:86
#10 <signal handler called>
#11 _int_malloc (av=0x7f8a2aa36720, bytes=10424) at malloc.c:3828
#12 0x00007f8a2a700fc5 in __GI___libc_malloc (bytes=10424) at malloc.c:2924
#13 0x00007f8a2b08ae49 in xmalloc (size=10424) at alloc.c:42



Thanks in advance,
Dimitris




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]