1

I'm working on a snow leopard machine (10.6.5) and I'm hunting a bug in our C++ application. However, I can't build our app with g++ -O0 -g, because the linker crashes:

g++-4.0 -arch i386 -arch x86_64 ...  -dynamic -bundle -o SOMELIB.dylib <SOME OBJECTS>...
collect2: ld terminated with signal 11 [Segmentation fault]
collect2: ld terminated with signal 11 [Segmentation fault]

I guess the two crashes are because there are two "-arch" flags. I managed to get a core file, which said the crash occurs in

(gdb) bt
#0  0x000000010001a2eb in Linker::synthesizeDebugNotes ()
#1  0x0000000100024cc5 in Linker::collectDebugInfo ()
#2  0x0000000100028198 in Linker::link ()
#3  0x000000010002a9eb in main ()

With this hint, I removed '-g' from the compiler flags, and everything builds fine. Moreover, most of our stuff builds fine with '-g', but just two of the big modules (.dylibs) don't, so I'm left with no debuginfo for those. And, ironically, the bug lurks just there, in one of these dylibs.

The bug is most likely due to an uninitialized memory use, as it manifests rarely, and running the app under valgrind reveals that there are a few uninitialized memory refences, but because of the missing debuginfo, it just says it happens inside module XXX (the dylib I can't compile with "-g")

So, I tried to download the ld utility from Apple's open source website, but I found (just like that guy) that it won't build because of a missing dependency to a Mac-specific version of libunwind, which Apple won't give away. Thus I can't recompile the linker.

So the next question is - what should I do now? I really wanted to avoid contacting Mac support...

ld version is "ld64 97.17", XCode is 3.2.5, gcc is 4.0.1.

I really need some directions...

anrieff
  • 619
  • 1
  • 6
  • 15
  • File a radar, or talk to the xcode mailing list. It's exceedingly unlikely that anyone can help you with these here. – bmargulies Dec 22 '10 at 15:28
  • Try using -ggdb or -gstabs or -gstabs+ or -gdwarf-2 to see if it makes a difference. Also perhaps try g++-4.2 instead of g++-4.0. Not sure it will help, but worth a try, I think. PS: I didn't know valgrind now works on OS X! Might be very useful. – Wodin Dec 22 '10 at 15:56

0 Answers0