[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
login shell crash on Mac OS X while closing file descriptors
From: |
Rainer Müller |
Subject: |
login shell crash on Mac OS X while closing file descriptors |
Date: |
Mon, 23 Aug 2010 18:38:34 +0200 |
User-agent: |
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.8) Gecko/20100802 Mnenhy/0.8.3 Thunderbird/3.1.2 |
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.
The important part of the crash report attached to the ticket above is:
| 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
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
- login shell crash on Mac OS X while closing file descriptors,
Rainer Müller <=