Re: problems with traps

2015-08-13 Thread Chet Ramey
On 8/12/15 9:55 PM, isabella parakiss wrote:
> This segfaults when it receives a SIGUSR1:
> 
> #!/bin/bash
> trap ': $(:) < <(:)' USR1
> while :; do sleep 1; done

Thanks for the report.  The problem is the process substitution in the
trap.  I will fix it for the next version of bash.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



problems with traps

2015-08-12 Thread isabella parakiss
This segfaults when it receives a SIGUSR1:

#!/bin/bash
trap ': $(:) < <(:)' USR1
while :; do sleep 1; done


I also received a bunch of scary errors like these:
*** Error in `/bin/bash': munmap_chunk(): invalid pointer:
0x02680f80 ***
*** Error in `/bin/bash': corrupted double-linked list: 0x01e54200 ***
*** Error in `/bin/bash': free(): invalid size: 0x0115ff80 ***
*** Error in `/bin/bash': double free or corruption (out):
0x00e7af60 ***
https://gist.github.com/anonymous/9b24b3ca0a6ce2203fc8
and bash used 100% of a cpu, but they appeared inconsistently while
trying to debug a script that trapped the SIGWINCH signal.
I'll post more details if needed (and if I can reproduce them).


>From gdb it looks like the problems are in jobs.c
This is the backtrace for the segfault, but it doesn't explain the rest:

Program received signal SIGSEGV, Segmentation fault.
0x0044d2e5 in find_pipeline (pid=19266, alive_only=1,
jobp=0x7fffdff8) at jobs.c:1357
1357  if (p->pid == pid && ((alive_only == 0 && PRECYCLED(p) == 0)
|| PALIVE(p)))
(gdb) bt
#0  0x0044d2e5 in find_pipeline (pid=19266, alive_only=1,
jobp=0x7fffdff8) at jobs.c:1357
#1  0x0044d419 in find_process (pid=19266, alive_only=1,
jobp=0x7fffdff8) at jobs.c:1396
#2  0x00450e0a in waitchld (wpid=-1, block=0) at jobs.c:3393
#3  0x00450b7c in sigchld_handler (sig=17) at jobs.c:3280
#4  
#5  0x0048e0c8 in builtin_address_internal (name=0x7645d0 ":",
disabled_okay=0) at common.c:829
#6  0x0048e251 in find_shell_builtin (name=0x7645d0 ":") at common.c:866
#7  0x0043c6bf in execute_simple_command
(simple_command=0x763e50, pipe_in=-1, pipe_out=-1, async=0,
fds_to_close=0x738220) at execute_cmd.c:4200
#8  0x004367f1 in execute_command_internal (command=0x763da0,
asynchronous=0, pipe_in=-1,
pipe_out=-1, fds_to_close=0x738220) at execute_cmd.c:813
#9  0x00435dd3 in execute_command (command=0x763da0) at
execute_cmd.c:416
#10 0x0043ae49 in execute_while_or_until
(while_command=0x764130, type=0) at execute_cmd.c:3432
#11 0x0043adb4 in execute_while_command
(while_command=0x764130) at execute_cmd.c:3400
#12 0x00436a55 in execute_command_internal (command=0x764240,
asynchronous=0, pipe_in=-1,
pipe_out=-1, fds_to_close=0x764050) at execute_cmd.c:920
#13 0x00435dd3 in execute_command (command=0x764240) at
execute_cmd.c:416
#14 0x00421a04 in reader_loop () at eval.c:163
#15 0x0041f856 in main (argc=2, argv=0x7fffe9b8,
env=0x7fffe9d0) at shell.c:760


Hope this helps...


---
xoxo iza