Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
366 views
in Technique[技术] by (71.8m points)

iphone - Building with LLVM and any optimization causes app to crash on startup

When I try to build my app with LLVM 2.0 in XCode 4.0.1 and any level or optimization that is not none (anything but -O0), the app crashes after i launch it on the device (simulator is ok). I can't seem to debug the crash as it does not happen when i build in xcode and attach via GDB/LLDB. Also, the crash only happens when i build the app on the command line with xcodebuild; building via the XCode IDE doesn't crash even with the exact same project settings. I can't see any useful information in the crash logs, as the crash happens outside my code:

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00b53400
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   ???                             0x00b53400 0 + 11875328

It won't symbolicate correctly since it doesn't know which library the crash happened in.

The device console shows some NSLog statements that our app makes at startup, then the first screen's UI is loaded and drawn, and after that the crash happens. Building with no optimizations, or building with GCC 4.2 with any optimization level works fine.

What could be happening here, and how can i debug it? What could the XCode IDE be doing differently when it builds and deploys the app vs. the xcodebuild command line interface?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

We've had the same issue with our app. It only affected armv6 code in Release/Distribution builds and thus only the iPhone 3G and the iPod Touch 2G. But contrary to your description, it was reproducible with XCode (we don't use xcodebuild).

Obviously the generated code corrupts the stack pointer. As a consequence, you can't really debug it and the crash logs are worthless. With the debugger, it could stop at viewWillAppear:animated of the first view that should be displayed. But quickly after that, the app always crashed.

Switching to an older compiler solved the problem.

I've filed a bug with Apple. Please file one too as it is said to increase the priority of the bug.

There are more people reporting the same problem:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...