Declaring an empty global var as a reference in a function twice crashes bash
Configuration Information: Machine: x86_64 OS: darwin13.3.0 Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='darwin13.3.0' -DCONF_MACHTYPE='x86_64-apple-darwin13.3.0' -DCONF_VENDOR='apple' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DMACOSX -I. -I. -I./include -I./lib -I./lib/int\ l -I/Users/apple/Downloads/bash-4.3/lib/intl -arch i386 -arch x86_64 -O3 -fomit-frame-pointer -momit-leaf-frame-pointer -ffast-math -fvisibility=hidden -march=core2 -mtune=corei3 -mmacosx-version-min=10.8 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platfo\ rm/Developer/SDKs/MacOSX10.8.sdk uname output: Darwin Z 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64 Machine Type: x86_64-apple-darwin13.3.0 Bash Version: 4.3 Patch Level: 26 Release Status: release Description: When you have already set a variable to empty, running `declare -gn varname` in a function twice crash bash with a Segment Fault. `set -xv` told me that bash would stop right when running declare. There is also some additional info from lldb. I have reproduced this on my OS X and Ubuntu 14.10 LTS amd64, and a bash 4.3.30 on the same OS X machine, in another prefix. The LLDB output was nearly identical. Repeat-By: Run this in bash, either as a script with she-bang or copy-paste in interactive shell: ```Bash #!/bin/bash v='' a(){ declare -gn v; } a; a ``` --LLDB-- * thread #1: tid = 0x922581, 0x000100074371 bash`declare_internal + 3729, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x29) frame #0: 0x000100074371 bash`declare_internal + 3729 bash`declare_internal + 3729: -> 0x100074371: orb$0x10, 0x29(%r14) 0x100074376: movq -0x58(%rbp), %rsi 0x10007437a: movl 0x28(%r14), %edx 0x10007437e: testb $0x2, %dl
Declaring an empty global var as a reference in a function twice crashes bash
Configuration Information: Machine: x86_64 OS: darwin13.3.0 Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='darwin13.3.0' -DCONF_MACHTYPE='x86_64-apple-darwin13.3.0' -DCONF_VENDOR='apple' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DMACOSX -I. -I. -I./include -I./lib -I./lib/int\ l -I/Users/apple/Downloads/bash-4.3/lib/intl -arch i386 -arch x86_64 -O3 -fomit-frame-pointer -momit-leaf-frame-pointer -ffast-math -fvisibility=hidden -march=core2 -mtune=corei3 -mmacosx-version-min=10.8 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platfo\ rm/Developer/SDKs/MacOSX10.8.sdk uname output: Darwin Z 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64 Machine Type: x86_64-apple-darwin13.3.0 Bash Version: 4.3 Patch Level: 26 Release Status: release Description: When you have already set a variable to empty, running `declare -gn varname` in a function twice crash bash with a Segment Fault. `set -xv` told me that bash would stop right when running declare. There is also some additional info from lldb. I have reproduced this on my OS X and Ubuntu 14.10 LTS amd64, and a bash 4.3.30 on the same OS X machine, in another prefix. The LLDB output was nearly identical. Repeat-By: Run this in bash, either as a script with she-bang or copy-paste in interactive shell: ```Bash #!/bin/bash v='' a(){ declare -gn v; } a; a ``` --LLDB-- * thread #1: tid = 0x922581, 0x000100074371 bash`declare_internal + 3729, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x29) frame #0: 0x000100074371 bash`declare_internal + 3729 bash`declare_internal + 3729: -> 0x100074371: orb$0x10, 0x29(%r14) 0x100074376: movq -0x58(%rbp), %rsi 0x10007437a: movl 0x28(%r14), %edx 0x10007437e: testb $0x2, %dl
Re: Declaring an empty global var as a reference in a function twice crashes bash
On 3/22/15 3:55 AM, Arthur20 wrote: > Bash Version: 4.3 > Patch Level: 26 > Release Status: release > > Description: > When you have already set a variable to empty, running `declare -gn > varname` in a function twice crash bash with a Segment Fault. Thanks for the report. This will be fixed in the next release 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/
bug in documentation?
Hey. The bash manpage says: >When a login shell exits, bash reads and executes commands from the >file ~/.bash_logout, if it exists. However, it seems that this happens only for interactive login shells,... at least I couldn't get it executed for non-interactive login shells with the --login option. Could you please clarify that? Thanks, Chris. smime.p7s Description: S/MIME cryptographic signature
Re: bug in documentation?
On 3/22/15 7:50 PM, Christoph Anton Mitterer wrote: > Hey. > > The bash manpage says: >> When a login shell exits, bash reads and executes commands from the >> file ~/.bash_logout, if it exists. > > However, it seems that this happens only for interactive login > shells,... at least I couldn't get it executed for non-interactive login > shells with the --login option. > > Could you please clarify that? It does when you call the exit builtin. EOF to an interactive shell executes the exit builtin, but you have to explicitly call it when in a non-interactive shell. -- ``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/
Re: bug in documentation?
Hey. On Sun, 2015-03-22 at 22:08 -0400, Chet Ramey wrote: > It does when you call the exit builtin. EOF to an interactive shell > executes the exit builtin, but you have to explicitly call it when in > a non-interactive shell. Ah... tricky :D Okay could you then please add this? Guess many others would also never found out without asking. Cheers, Chris. smime.p7s Description: S/MIME cryptographic signature