Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!usenet.stanford.edu!not-for-mail From: jtmoon+bashbug@extrahop.com Newsgroups: gnu.bash.bug Subject: trap RETURN not set in calling function is overwritten by callee Date: Tue, 18 Aug 2015 23:48:52 -0700 (PDT) Lines: 35 Approved: bug-bash@gnu.org Message-ID: NNTP-Posting-Host: lists.gnu.org X-Trace: usenet.stanford.edu 1439998716 27820 208.118.235.17 (19 Aug 2015 15:38:36 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org,bash@packages.debian.org Envelope-to: bug-bash@gnu.org X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:message-id:date; bh=EYn9HJdQO1M6p9UGzhZuLbfAC+hGssd2BXw4RyGfyug=; b=ZtS9dtebdgxTVY9mHhCuYuJ2dFLfJ9zHlx5rQNaetmZwMU3i2qDAs1E0YPLjqN8laD VBABoojGzbEGIWq+MqAV0b8rb57lhpjzpcPMpk/17yexCNoAg5qMVH46fwQ7DzxRNlMT 4YhGLOl3oNUOMfX2J3qcef74wiGDLjbc5w6NKKIU3xUU8iYjJ8sDYM/6LhHpHb269J7M R/fc42BNgJUNkOn6trYzxyBSrU7eIIiQfyQQaEB6ckhB7MjAshmrNzBhPcTiQDE+VRq9 JVWaJCimOu9dTuXmGpOtl2ZKBauBsoMjjK/MPaPYbhvbcBIBa6lZvNSiIQqpiHZAEdHF Wulw== X-Gm-Message-State: ALoCoQl9oNsjx62lB3FsWsnG7/G/2z7Ic7USr/a24PGPc15PZJfUsiaNcAIuoQnAgzVQeutxzlwm3FVeMMtsfI7ulSoFNK/rPA== X-Received: by 10.70.90.98 with SMTP id bv2mr21733034pdb.36.1439966933255; Tue, 18 Aug 2015 23:48:53 -0700 (PDT) X-Relaying-Domain: extrahop.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.97 X-Mailman-Approved-At: Wed, 19 Aug 2015 11:38:34 -0400 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:11397 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.