From what I've heard, there was a bug in the gcc bundled with Xcode
2.3 that caused stack alignment issues when -O2 was used (and maybe -O1?). This is supposed to be fixed in Xcode 2.4, which is what I'm using, yet I'm still getting a "Bus Error" with all default CFLAGS. Adding -O0 into the mix fixes the problem.
Here's all I could gleam with gdb:
Breakpoint 1, NtAllocateVirtualMemory (process=0x7bc5b6f1, ret=0xbffff949, zero_bits=3221222220, size_ptr=0x10000, type=3221222216, protect=2147352576) at virtual.c:1306 1306 in virtual.c (gdb) bt #0 NtAllocateVirtualMemory (process=0x7bc5b6f1, ret=0xbffff949, zero_bits=3221222220, size_ptr=0x10000, type=3221222216, protect=2147352576) at virtual.c:1306 #1 0x7bc4f428 in thread_init () at thread.c:224 #2 0x7bc2beea in __wine_process_init () at loader.c:2354 #3 0x60a088c1 in wine_init (argc=2, argv=0xbffff8b8, error=0xbffff450 "", error_size=1024) at loader.c:664 #4 0x7bf00f2d in main (argc=2, argv=0xbffff8b8) at main.c:58 [stepping...] (gdb) step NtAllocateVirtualMemory (process=0x2001, ret=0xbffff22c, zero_bits=1048576, size_ptr=0x1000, type=4294967295, protect=10514258) at virtual.c:1379 1379 in virtual.c (gdb) print status $22 = 0 [stepping...] (gdb) step thread_init () at thread.c:226 226 thread.c: No such file or directory. in thread.c (gdb) print addr $23 = (void *) 0x7ffde000 (gdb) print size $24 = 4096 (gdb) step 228 in thread.c (gdb) step
Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x7ffde064 thread_init () at thread.c:228 228 in thread.c (gdb) bt #0 thread_init () at thread.c:228 #1 0x7bc2beea in __wine_process_init () at loader.c:2354 #2 0x60a088c1 in wine_init (argc=2, argv=0xbffff8b8, error=0xbffff450 "", error_size=1024) at loader.c:664 #3 0x7bf00f2d in main (argc=2, argv=0xbffff8b8) at main.c:58 (gdb)
thread.c:228 being "peb->NumberOfProcessors = 1;", and peb being 0x7ffde000.
Here's some environment information:
OS: Mac OS X 10.4.7 Xcode: Xcode 2.4 X11: XFree86 Version 4.4.0 / X Window System (protocol Version 11, revision 0, vendor release 6600)
gcc -v: Using built-in specs. Target: i686-apple-darwin8 Configured with: /private/var/tmp/gcc/gcc-5363.obj~28/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=powerpc-apple-darwin8 --with-arch=nocona --with-tune=generic --program-prefix= --host=i686-apple-darwin8 --target=i686-apple-darwin8 Thread model: posix gcc version 4.0.1 (Apple Computer, Inc. build 5363)
uname -a: Darwin my-computer 8.7.1 Darwin Kernel Version 8.7.1: Wed Jun 7 16:19:56 PDT 2006; root:xnu-792.9.72.obj~2/RELEASE_I386 i386 i386
I've built Wine with the following DarwinPorts portfile:
# $Id: $ PortSystem 1.0 name wine version 0.9.20 description Windows compatibility layer long_description Microsoft Windows compatibility layer for Unix-like systems categories emulators maintainers dackze+darwinports@gmail.com platforms darwin freebsd homepage http://www.winehq.org/ master_sites sourceforge:wine use_bzip2 yes depends_lib bin:bison:bison bin:fontforge:fontforge bin:gmake:gmake \ bin:m4:m4 bin:pkg-config:pkgconfig \ lib:libfontconfig:fontconfig lib:libfreetype:freetype \ lib:libintl:gettext lib:libjpeg:jpeg lib:libncurses:ncurses \ lib:libX11:XFree86 lib:liblcms:lcms lib:libglut:glut \ lib:libgphoto2:libgphoto2 lib:libsane:sane-backends \ lib:libssl:openssl lib:libungif:libungif \ lib:libxml2:libxml2 lib:libxslt:libxslt build.type gnu
checksums ${distname}${extract.suffix} md5 3e80a07819e4df084becdbbcd4d6cdd3 \ sha1 71b918dcdc54bc32e0b37a63f66891bb7c96b938 \ rmd160 80f1a055674b56ec7cb9231d08b837d1a1a4e883
platform darwin powerpc { ui_msg "Wine is not supported on PowerPC" exit 1 }
Which installs the following:
fontforge @20060125_0 (active) freetype @2.1.10_1 (active) gettext @0.14.6_0 (active) glut @3.7_0 (active) gmake @3.81_0 (active) jpeg @6b_1 (active) lcms @1.15_0 (active) libgphoto2 @2.1.5_0 (active) libiconv @1.10_1+darwin_8 (active) libpng @1.2.10_2+darwin_8 (active) libungif @4.1.4_0 (active) libuninameslist @20050712_0 (active) libusb @0.1.12_0 (active) pkgconfig @0.21_0 (active) sane-backends @1.0.17_0+local-backends (active) tiff @3.8.2_0+darwin_8 (active) wine @0.9.20_0 (active) zlib @1.2.3_0 (active)