bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Combination of ERR, EXIT, DEBUG traps causes segmentation fault on Bash


From: self
Subject: Combination of ERR, EXIT, DEBUG traps causes segmentation fault on Bash 4.3.11
Date: Fri, 11 Mar 2016 06:25:10 -0800 (PST)
User-agent: G2/1.0

The following script cause Segmentation fault. I cleaned up the source, so 
removing any line "fixes" the problem.


$ ./sandbox.sh 
Segmentation fault (core dumped)


$ cat sandbox.sh 
#!/usr/bin/env bash

set -o errtrace
set -o functrace

SESSION="$( mktemp -d session.XXXXXXXXXX )"

on_exit() {
    rm -r "$SESSION"
}

on_error() {
    foo="$( echo 'bar' )"
    return 0
}

on_debug() {
    return 0
}

trap 'on_error' ERR
trap 'on_exit'  EXIT
trap 'on_debug' DEBUG

false


$ bash --version
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


$ gdb bash
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from bash...(no debugging symbols found)...done.
(gdb) run sandbox.sh
Starting program: /bin/bash sandbox.sh

Program received signal SIGSEGV, Segmentation fault.
0x00000000004b435a in ?? ()
(gdb) bt
#0  0x00000000004b435a in ?? ()
#1  0x00000000004436a6 in ?? ()
#2  0x0000000000444daf in cleanup_the_pipeline ()
#3  0x0000000000444e43 in start_pipeline ()
#4  0x0000000000446a3f in make_child ()
#5  0x0000000000434796 in ?? ()
#6  0x0000000000435ff0 in execute_command_internal ()
#7  0x0000000000435cdb in execute_command_internal ()
#8  0x0000000000438ddf in ?? ()
#9  0x0000000000435299 in ?? ()
#10 0x0000000000435ff0 in execute_command_internal ()
#11 0x000000000047879f in parse_and_execute ()
#12 0x000000000045acca in run_exit_trap ()
#13 0x000000000042090c in exit_shell ()
#14 0x000000000041f764 in main ()
(gdb) 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]