err = noErr; // Intel binary (only) crashes here
err = noErr; // Intel binary (only) crashes here
- Subject: err = noErr; // Intel binary (only) crashes here
- From: Robert Purves <email@hidden>
- Date: Sun, 2 Sep 2007 17:48:24 +1200
An apparent bug in gcc and/or Darwin, demonstrable in half a dozen
lines of code, and leading to a crash. Am I missing something, or is
it time to visit bugreport.apple.com?
$ cat bug_demo.c
#include <Carbon/Carbon.h>
OSStatus err;
int main( void )
{
SysBeep( 1 ); // any Carbon function
err = noErr; // Intel binary (only) crashes here
return 0;
}
$ gcc bug_demo.c -framework Carbon -g && ./a.out
Bus error
EXC_BAD_ACCESS (0x0001)
KERN_PROTECTION_FAILURE (0x0002) at 0x900dd686
Thread 0 Crashed:
0 main + 32 (bug_demo.c:7)
1 _start + 216
2 start + 41
0x900dd686 seems an unlikely address for a global. Is there something
weird about err? Changing the declaration to a definition:
OSStatus err = 1;
suggests the answer "Very weird indeed"
$ gcc bug_demo.c -framework Carbon -g && ./a.out
/usr/bin/ld: warning multiple definitions of symbol _err
/var/tmp//cc4X2C6Z.o definition of _err in section (__DATA,__data)
/usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libSystem.dylib
(err.So) definition of _err
$ gcc --version
i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build
5367)
Robert P.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden