Hi,
I am the maintainer of bash in MacPorts, a package management system for
Mac OS X. I am currently debugging crashes with bash 4.1.7 when being
run as a login shell under certain conditions. The original report was
here: http://trac.macports.org/ticket/25693
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: darwin10.4.0
Compiler: /usr/bin/gcc-4.2
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='darwin10.4.0' -DCONF_MACHTYPE='i386-apple-darwin10.4.0'
-DCONF_VENDOR='apple' -DLOCALEDIR='/opt/local/share/locale'
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DMACOSX -I. -I. -I./include
-I./lib -I/opt/local/include -pipe -O2 -arch x86_64
uname output: Darwin Dysnomia.local 10.4.0 Darwin Kernel Version 10.4.0:
Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386
Machine Type: i386-apple-darwin10.4.0
Bash Version: 4.1
Patch Level: 7
Release Status: release
I cannot reproduce this very good, but it happens for me now with
iTerm.app and '/opt/local/bin/bash -l' as command. A crash report is
attached to this message.
The important part of this report is:
"BUG IN CLIENT OF LIBDISPATCH: Do not close random Unix descriptors"
I tracked this down to the shell initialization in the main function,
where bash closes any open file descriptors in the range from 3 to 19.
Apparently this causes problems with libdispatch, Apple's threading
library, as it works fine if I comment this section out.
This is the code in question:
| #define CLOSE_FDS_AT_LOGIN
| #if defined (CLOSE_FDS_AT_LOGIN)
| /*
| * Some systems have the bad habit of starting login shells with
lots of open
| * file descriptors. For instance, most systems that have picked up the
| * pre-4.0 Sun YP code leave a file descriptor open each time you
call one
| * of the getpw* functions, and it's set to be open across execs. That
| * means one for login, one for xterm, one for shelltool, etc.
| */
| if (login_shell && interactive_shell)
| {
| for (i = 3; i < 20; i++)
| close (i);
| }
| #endif /* CLOSE_FDS_AT_LOGIN */
I am not sure how to proceed so I am asking for advice. Should I just
remove this code with a patch and let bash ignore any open file
descriptors? Would that be bad? Any other ideas?
Rainer
Process: bash [418]
Path: /opt/local/bin/bash
Identifier: bash
Version: ??? (???)
Code Type: X86-64 (Native)
Parent Process: ??? [417]
Date/Time: 2010-08-20 19:34:27.967 +0200
OS Version: Mac OS X 10.6.4 (10F569)
Report Version: 6
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Crashed Thread: 1 Dispatch queue: com.apple.libdispatch-manager
Application Specific Information:
BUG IN CLIENT OF LIBDISPATCH: Do not close random Unix descriptors
Thread 0: Dispatch queue: com.apple.main-thread
0 libSystem.B.dylib 0x00007fff8439d8e6 read + 10
1 bash 0x0000000100054754 _evalfile + 996
2 bash 0x0000000100054bd1 maybe_execute_file +
49
3 bash 0x0000000100001638 run_startup_files +
568
4 bash 0x00000001000031a8 main + 4264
5 bash 0x0000000100001054 start + 52
Thread 1 Crashed: Dispatch queue: com.apple.libdispatch-manager
0 libSystem.B.dylib 0x00007fff843ae1b0 _dispatch_mgr_invoke
+ 749
1 libSystem.B.dylib 0x00007fff843adc34
_dispatch_queue_invoke + 185
2 libSystem.B.dylib 0x00007fff843ad75e
_dispatch_worker_thread2 + 252
3 libSystem.B.dylib 0x00007fff843ad088 _pthread_wqthread +
353
4 libSystem.B.dylib 0x00007fff843acf25 start_wqthread + 13
Thread 2:
0 libSystem.B.dylib 0x00007fff843aceaa __workq_kernreturn +
10
1 libSystem.B.dylib 0x00007fff843ad2bc _pthread_wqthread +
917
2 libSystem.B.dylib 0x00007fff843acf25 start_wqthread + 13
Thread 1 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000009 rbx: 0x00000000ffffffff rcx: 0x00007fff844e9840
rdx: 0xffffffffffffffff
rdi: 0x0000000000000009 rsi: 0x0000000000000000 rbp: 0x00000001002f4e90
rsp: 0x00000001002f4cf0
r8: 0x0000000000000001 r9: 0x00000001002f4e50 r10: 0x00000001002f4e20
r11: 0x00007fff708714b8
r12: 0x00007fff70859978 r13: 0x00007fff70859d48 r14: 0xffffffffffffffff
r15: 0x00007fff70859d88
rip: 0x00007fff843ae1b0 rfl: 0x0000000000010246 cr2: 0x0000000100039970
Binary Images:
0x100000000 - 0x100099fe7 +bash ??? (???)
<1E9C0EAD-E5A5-B773-3E66-EE7B5417FF24> /opt/local/bin/bash
0x1000bf000 - 0x1000e9ff7 +libncurses.5.dylib 5.0.0
(compatibility 5.0.0) <9829BCEB-0A54-5FA7-788E-0F0593301164>
/opt/local/lib/libncurses.5.dylib
0x1000f5000 - 0x10011dff7 +libreadline.6.1.dylib 6.1.0
(compatibility 6.0.0) <B3D04290-A519-E00B-B187-297070310424>
/opt/local/lib/libreadline.6.1.dylib
0x100133000 - 0x100139fff +libhistory.6.1.dylib 6.1.0
(compatibility 6.0.0) <863F7DDC-C3AE-C9EC-08EB-315FDEE9C697>
/opt/local/lib/libhistory.6.1.dylib
0x10013d000 - 0x100146ff7 +libintl.8.dylib 10.1.0 (compatibility
10.0.0) <D1004391-54AA-C4FD-47A1-80B94415BD62> /opt/local/lib/libintl.8.dylib
0x10014c000 - 0x100248fe7 +libiconv.2.dylib 8.0.0 (compatibility
8.0.0) <6907D6DB-2535-7725-484F-74378F42AFED> /opt/local/lib/libiconv.2.dylib
0x7fff5fc00000 - 0x7fff5fc3bdef dyld 132.1 (???)
<B536F2F1-9DF1-3B6C-1C2C-9075EA219A06> /usr/lib/dyld
0x7fff80c08000 - 0x7fff80d7dff7 com.apple.CoreFoundation 6.6.3
(550.29) <48810602-63C3-994D-E563-DD02B16E76E1>
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x7fff814ed000 - 0x7fff815a3fff libobjc.A.dylib 227.0.0 (compatibility
1.0.0) <F206BE6D-8777-AE6C-B367-7BEA76C14241> /usr/lib/libobjc.A.dylib
0x7fff8368a000 - 0x7fff8368eff7 libmathCommon.A.dylib 315.0.0
(compatibility 1.0.0) <95718673-FEEE-B6ED-B127-BCDBDB60D4E5>
/usr/lib/system/libmathCommon.A.dylib
0x7fff83fc1000 - 0x7fff83fd2ff7 libz.1.dylib 1.2.3 (compatibility
1.0.0) <FB5EE53A-0534-0FFA-B2ED-486609433717> /usr/lib/libz.1.dylib
0x7fff84392000 - 0x7fff84552fef libSystem.B.dylib 125.2.0
(compatibility 1.0.0) <95E02DD0-ADEA-745B-E7FA-ABA064E4658C>
/usr/lib/libSystem.B.dylib
0x7fff8594d000 - 0x7fff85999fff libauto.dylib ??? (???)
<072804DF-36AD-2DBE-7EF8-639CFB79077F> /usr/lib/libauto.dylib
0x7fff86a64000 - 0x7fff86ae1fef libstdc++.6.dylib 7.9.0 (compatibility
7.0.0) <35ECA411-2C08-FD7D-11B1-1B7A04921A5C> /usr/lib/libstdc++.6.dylib
0x7fff879b2000 - 0x7fff87b70fff libicucore.A.dylib 40.0.0
(compatibility 1.0.0) <0E53A4A6-AC06-1B61-2285-248F534EE356>
/usr/lib/libicucore.A.dylib
0x7fffffe00000 - 0x7fffffe01fff libSystem.B.dylib ??? (???)
<95E02DD0-ADEA-745B-E7FA-ABA064E4658C> /usr/lib/libSystem.B.dylib