On 3/6/12 7:59 AM, Siddhesh Poyarekar wrote: > Bash Version: 4.2 > Patch Level: 20 > Release Status: release > > Description: > > When a SIGCHLD is received in job control mode and a handler for the > signal is installed, bash calls the trap handler within the signal > handler itself. This is unsafe because the trap handler function > run_sigchld_trap() uses the glibc malloc functions quite extensively > (within the function itself and also the function it calls, i.e. > parse_and_execute() ). This results in a deadlock and sometimes even a > segmentation fault due to memory corruption. > > Repeat-By: > > $ cat > foo.sh > #!/bin/sh > > check_stop_child_trap() { > echo "child died!" > } > > do_something() { > while true; do > true & > done > } > > trap check_stop_child_trap SIGCHLD > do_something & > do_something > > ^d > > $ bash > $ . foo.sh > > ------------------ > > The above may either hang or result in a segmentation fault. > > Fix: > > The attached patch fixes this by deferring execution of the trap > handler by adding it to pending_sigs.
Good catch. Thanks for the report. The fix will be in the next release of bash. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/