Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[BUG] Crash due to malloc call in signal handler



Hello,

I finally found the cause of the frequent crashes I reported one
year ago ( https://www.zsh.org/mla/workers/2019/msg00059.html ).

This is due to malloc calls from signal handler, for instance:

#0  tcache_get (tc_idx=17) at malloc.c:2943
#1  __GI___libc_malloc (bytes=296) at malloc.c:3050
#2  0x000055c2217b27b5 in malloc (size=8) at ./main.c:255
#3  0x000055c2218166f9 in zalloc (size=8) at mem.c:966
#4  0x000055c221806da2 in addbgstatus (pid=11959, status=0) at jobs.c:2192
#5  0x000055c2218478e7 in wait_for_processes () at signals.c:583
#6  0x000055c221847cdc in zhandler (sig=17) at signals.c:648
#7  <signal handler called>
#8  0x00007f8895b69209 in __GI___sigsuspend (set=0x7ffe759b7160) at ../sysdeps/unix/sysv/linux/sigsuspend.c:26
#9  0x000055c221847376 in signal_suspend (sig=17, wait_cmd=1) at signals.c:393
#10 0x000055c2218054e8 in waitforpid (pid=11953, wait_cmd=1) at jobs.c:1551
#11 0x000055c221807a10 in bin_fg (name=0x7f8896af4798 "wait", argv=0x7f8896af4830, ops=0x7ffe759b75c0, func=4) at jobs.c:2371

All the backtraces I get does not always show a signal, and I 
get a lot a various errors occuring either in a malloc or a free;
however, I have been debugging this problem by enabling mcheck(),
and in this very case, all the crashes occur within freehook() 
and when tracing back the associated malloc() I can find it 
always occurs during double interlaced malloc() calls from the
main and signal contexts.

I can provide more info to reproduce the problem.

Antoine



Messages sorted by: Reverse Date, Date, Thread, Author