[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Declaring an empty global var as a reference in a function twice crashes
From: |
铭烨王 |
Subject: |
Declaring an empty global var as a reference in a function twice crashes bash |
Date: |
Sun, 22 Mar 2015 15:59:44 +0800 |
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 Zzzzz 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, 0x0000000100074371 bash`declare_internal
+ 3729, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x29)
frame #0: 0x0000000100074371 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,
铭烨王 <=