This is the mail archive of the 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]

malloc/free is signal-safe?

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,

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