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

Re: Deadlock when receiving kill-signal from child process



On Thu, Aug 6, 2015 at 8:06 AM, Bart Schaefer wrote:
}
} I played around with this a bit by hacking loop() but the effect is
} that with the test script Mathais provided, most of the USR1 signals
} are just thrown away (they collapse into a single call to the trap
} handler).  Not sure if that's actually the desired effect.

I would imagine some might rely on every signal being handled, e.g.
keeping a count.

}
} You mean disowned, I presume, since all children are by definition forked.

Yes, sorry for being unclear.

}
} Whack-a-mole continues.  Does the behavior change if you
}         setopt NO_TRAPS_ASYNC
} ??

Heh, that's exactly what this feels like. But I don't think it changes
the behavior, this is pre-patch with NO_TRAPS_ASYNC set:

#0  0x00007fff8abf95da in syscall_thread_switch ()
#1  0x00007fff853a982d in _OSSpinLockLockSlow ()
#2  0x00007fff896e16d9 in szone_force_lock ()
#3  0x00007fff896e15e6 in _malloc_fork_prepare ()
#4  0x00007fff82cb8097 in fork ()
#5  0x00000001074b166c in zfork ()
#6  0x00000001074b50f9 in execcmd ()
#7  0x00000001074b015c in execpline ()
#8  0x00000001074af706 in execlist ()
#9  0x00000001074af52e in execode ()
#10 0x00000001074b3133 in runshfunc ()
#11 0x00000001074b2c1e in doshfunc ()
#12 0x00000001074f788a in dotrapargs ()
#13 0x00000001074f69ed in handletrap ()
#14 0x00000001074f62fc in zhandler ()
#15 <signal handler called>
#16 0x00007fff896ddfc7 in small_free_list_add_ptr ()
#17 0x00007fff896d9ccf in szone_free_definite_size ()
#18 0x00000001074e6c46 in bld_eprog ()
#19 0x00000001074c7c70 in loop ()
#20 0x00000001074caac8 in zsh_main ()
#21 0x00007fff8610c5c9 in start ()

}
} Next question is how much are we slowing down the shell with all of this
} signal management.

By just casual observation I can't tell a difference. I guess proper
benchmarks would be required.

The following traces have the last patches applied (I did multiple
runs to see if I could hit different states):

#0  0x00007fff8abf95da in syscall_thread_switch ()
#1  0x00007fff853a982d in _OSSpinLockLockSlow ()
#2  0x00007fff896d771b in szone_malloc_should_clear ()
#3  0x00007fff896d7667 in malloc_zone_malloc ()
#4  0x00007fff896d6187 in malloc ()
#5  0x000000010df5deaf in zalloc ()
#6  0x000000010df7e2ca in ztrdup ()
#7  0x000000010df889b3 in mb_niceformat ()
#8  0x000000010df881cd in zwarning ()
#9  0x000000010df88376 in zwarn ()
#10 0x000000010df7c3da in wait_for_processes ()
#11 0x000000010df7c0a6 in zhandler ()
#12 <signal handler called>
#13 0x00007fff896dad62 in tiny_free_list_add_ptr ()
#14 0x00007fff896d9e7f in szone_free_definite_size ()
#15 0x000000010df38e63 in runshfunc ()
#16 0x000000010df38936 in doshfunc ()
#17 0x000000010df7d70b in dotrapargs ()
#18 0x000000010df7c7b2 in handletrap ()
#19 0x000000010df7c0b0 in zhandler ()
#20 0x000000010df36775 in execpline ()
#21 0x000000010df3541e in execlist ()
#22 0x000000010df35246 in execode ()
#23 0x000000010df4db8f in loop ()
#24 0x000000010df507e0 in zsh_main ()
#25 0x00007fff8610c5c9 in start ()

--

#0  0x00007fff8abfe166 in __psynch_mutexwait ()
#1  0x00007fff8e4b578a in _pthread_mutex_lock ()
#2  0x00007fff82ce5750 in fputc ()
#3  0x000000010b17ccd5 in zputs ()
#4  0x000000010b17cb3c in mb_niceformat ()
#5  0x000000010b17c1cd in zwarning ()
#6  0x000000010b17c376 in zwarn ()
#7  0x000000010b1703da in wait_for_processes ()
#8  0x000000010b1700a6 in zhandler ()
#9  <signal handler called>
#10 0x00007fff8abfe72a in __sigsuspend ()
#11 0x000000010b170287 in signal_suspend ()
#12 0x000000010b147671 in zwaitjob ()
#13 0x000000010b1474c4 in waitjobs ()
#14 0x000000010b12a238 in execpline ()
#15 0x000000010b12941e in execlist ()
#16 0x000000010b129246 in execode ()
#17 0x000000010b12ce4b in runshfunc ()
#18 0x000000010b12c936 in doshfunc ()
#19 0x000000010b17170b in dotrapargs ()
#20 0x000000010b1707b2 in handletrap ()
#21 0x000000010b1700b0 in zhandler ()
#22 <signal handler called>
#23 0x00007fff8abfe166 in __psynch_mutexwait ()
#24 0x00007fff8e4b578a in _pthread_mutex_lock ()
#25 0x00007fff82ce5750 in fputc ()
#26 0x000000010b17ccd5 in zputs ()
#27 0x000000010b17cb3c in mb_niceformat ()
#28 0x000000010b17c1cd in zwarning ()
#29 0x000000010b17c376 in zwarn ()
#30 0x000000010b1703da in wait_for_processes ()
#31 0x000000010b1700a6 in zhandler ()
#32 <signal handler called>
#33 0x00007fff853a9340 in OSAtomicCompareAndSwapPtrBarrier$VARIANT$mp ()
#34 0x00007fff8e4b5714 in _pthread_mutex_lock ()
#35 0x00007fff82ce43a3 in ferror ()
#36 0x000000010b141bc2 in loop ()
#37 0x000000010b1447e0 in zsh_main ()
#38 0x00007fff8610c5c9 in start ()

setopt NO_ASYNC_TRAPS:

#0  0x00007fff8abf95da in syscall_thread_switch ()
#1  0x00007fff853a982d in _OSSpinLockLockSlow ()
#2  0x00007fff896d771b in szone_malloc_should_clear ()
#3  0x00007fff896d7667 in malloc_zone_malloc ()
#4  0x00007fff896d6187 in malloc ()
#5  0x00000001081e2eaf in zalloc ()
#6  0x00000001082032ca in ztrdup ()
#7  0x000000010820d9b3 in mb_niceformat ()
#8  0x000000010820d1cd in zwarning ()
#9  0x000000010820d376 in zwarn ()
#10 0x00000001082013da in wait_for_processes ()
#11 0x00000001082010a6 in zhandler ()
#12 <signal handler called>
#13 0x00007fff896da116 in szone_free_definite_size ()
#14 0x00000001081bde63 in runshfunc ()
#15 0x00000001081bd936 in doshfunc ()
#16 0x000000010820270b in dotrapargs ()
#17 0x00000001082017b2 in handletrap ()
#18 0x00000001082029ec in unqueue_traps ()
#19 0x00000001081d872b in zwaitjob ()
#20 0x00000001081d84c4 in waitjobs ()
#21 0x00000001081bb238 in execpline ()
#22 0x00000001081ba41e in execlist ()
#23 0x00000001081ba246 in execode ()
#24 0x00000001081d2b8f in loop ()
#25 0x00000001081d57e0 in zsh_main ()
#26 0x00007fff8610c5c9 in start ()

--

#0  0x00007fff8abfe72a in __sigsuspend ()
#1  0x000000010af61287 in signal_suspend ()
#2  0x000000010af38671 in zwaitjob ()
#3  0x000000010af384c4 in waitjobs ()
#4  0x000000010af1b238 in execpline ()
#5  0x000000010af1a41e in execlist ()
#6  0x000000010af1a246 in execode ()
#7  0x000000010af1de4b in runshfunc ()
#8  0x000000010af1d936 in doshfunc ()
#9  0x000000010af6270b in dotrapargs ()
#10 0x000000010af617b2 in handletrap ()
#11 0x000000010af610b0 in zhandler ()
#12 <signal handler called>
#13 0x00007fff82ce43a8 in ferror ()
#14 0x000000010af32bc2 in loop ()
#15 0x000000010af357e0 in zsh_main ()
#16 0x00007fff8610c5c9 in start ()



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