On Friday 25,January,2013 12:28 AM, Chet Ramey wrote: > On 1/24/13 8:35 AM, konsolebox wrote: >> Hi. Is there a way to prevent this segmentation fault in Bash? I'm not sure >> where the fault happens but when there's a function that handles a trap and >> when a signal is caught during a session of read with -t, Bash crashes. An >> example code that makes this happen is this: > > I ran this script through around 6000 cycles on RHEL 5 using bash-4.2.42, > built with and without the bash malloc, and didn't see a crash.
It's about "luck". Well ... I also produce this problem. > How about a stack traceback from one of the crashes you get? *** glibc detected *** /bin/bash: double free or corruption (fasttop): 0x0000000001810d30 *** ======= Backtrace: ========= /lib64/libc.so.6[0x34e5275676] /bin/bash(read_builtin+0x143d)[0x47170d] /bin/bash[0x42d54e] /bin/bash[0x42f4f2] /bin/bash(execute_command_internal+0x943)[0x430113] /bin/bash[0x433283] /bin/bash(execute_command_internal+0x89d)[0x43006d] /bin/bash(execute_command+0x4e)[0x430dbe] /bin/bash[0x4316e7] /bin/bash(execute_command_internal+0xa45)[0x430215] /bin/bash(execute_command+0x4e)[0x430dbe] /bin/bash(reader_loop+0xa6)[0x41d526] /bin/bash(main+0xe5e)[0x41ccde] /lib64/libc.so.6(__libc_start_main+0xfd)[0x34e521ec5d] /bin/bash[0x41af19] ======= Memory map: ======== 00400000-004d5000 r-xp 00000000 fd:00 131170 /bin/bash 006d4000-006de000 rw-p 000d4000 fd:00 131170 /bin/bash 006de000-006e3000 rw-p 00000000 00:00 0 008dd000-008e6000 rw-p 000dd000 fd:00 131170 /bin/bash 01806000-01827000 rw-p 00000000 00:00 0 [heap] 31b4600000-31b461d000 r-xp 00000000 fd:00 2883648 /lib64/libtinfo.so.5.7 31b461d000-31b481d000 ---p 0001d000 fd:00 2883648 /lib64/libtinfo.so.5.7 31b481d000-31b4821000 rw-p 0001d000 fd:00 2883648 /lib64/libtinfo.so.5.7 34e4e00000-34e4e1e000 r-xp 00000000 fd:00 2883634 /lib64/ld-2.12.so 34e501e000-34e501f000 r--p 0001e000 fd:00 2883634 /lib64/ld-2.12.so 34e501f000-34e5020000 rw-p 0001f000 fd:00 2883634 /lib64/ld-2.12.so 34e5020000-34e5021000 rw-p 00000000 00:00 0 34e5200000-34e5375000 r-xp 00000000 fd:00 2883959 /lib64/libc-2.12.so 34e5375000-34e5575000 ---p 00175000 fd:00 2883959 /lib64/libc-2.12.so 34e5575000-34e5579000 r--p 00175000 fd:00 2883959 /lib64/libc-2.12.so 34e5579000-34e557a000 rw-p 00179000 fd:00 2883959 /lib64/libc-2.12.so 34e557a000-34e557f000 rw-p 00000000 00:00 0 34e5600000-34e5602000 r-xp 00000000 fd:00 2884013 /lib64/libdl-2.12.so 34e5602000-34e5802000 ---p 00002000 fd:00 2884013 /lib64/libdl-2.12.so 34e5802000-34e5803000 r--p 00002000 fd:00 2884013 /lib64/libdl-2.12.so 34e5803000-34e5804000 rw-p 00003000 fd:00 2884013 /lib64/libdl-2.12.so 34e9200000-34e9216000 r-xp 00000000 fd:00 2884025 /lib64/libgcc_s-4.4.4-20100726.so.1 34e9216000-34e9415000 ---p 00016000 fd:00 2884025 /lib64/libgcc_s-4.4.4-20100726.so.1 34e9415000-34e9416000 rw-p 00015000 fd:00 2884025 /lib64/libgcc_s-4.4.4-20100726.so.1 7f89a4b3e000-7f89a4b3f000 rw-p 00000000 00:00 0 7f89a4b3f000-7f89a4b46000 r--s 00000000 fd:00 1312117 /usr/lib64/gconv/gconv-modules.cache 7f89a4b46000-7f89aa9d7000 r--p 00000000 fd:00 1055982 /usr/lib/locale/locale-archive 7f89aa9d7000-7f89aa9dc000 rw-p 00000000 00:00 0 7fff6514a000-7fff65160000 rw-p 00000000 00:00 0 [stack] 7fff651ff000-7fff65200000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] Aborted (core dumped) > > Chet >