Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11397 > unrolled thread

trap RETURN not set in calling function is overwritten by callee

Started byjtmoon+bashbug@extrahop.com
First post2015-08-18 23:48 -0700
Last post2015-08-18 23:48 -0700
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug


Contents

  trap RETURN not set in calling function is overwritten by callee jtmoon+bashbug@extrahop.com - 2015-08-18 23:48 -0700

#11397 — trap RETURN not set in calling function is overwritten by callee

Fromjtmoon+bashbug@extrahop.com
Date2015-08-18 23:48 -0700
Subjecttrap RETURN not set in calling function is overwritten by callee
Message-ID<mailman.8636.1439998716.904.bug-bash@gnu.org>
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall
uname output: Linux moonrock 3.13.0-48-generic #80-Ubuntu SMP Thu Mar 12 11:16:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.3
Patch Level: 11
Release Status: release

Description:
	Given two functions wherein only one function sets a RETURN trap.  The other
        function will mistakenly call the other's RETURN trap upon it's return.

Repeat-By:
	# test trap RETURN if unset from called function
	function testU1() {
	    function _testU1_ret() { echo "${FUNCNAME}" ; }
	    trap _testU1_ret RETURN
	}
	function testU2() {
	    testU1
	    # when testU2 returns, will it call _testU1_ret ?
	}
	testU2
	# prints the following
	_testU1_ret
	_testU1_ret

Fix:
	For some reason the RETURN traps are not being stacked.  Instead, the
	current RETURN trap is just overwritten.

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web