问题
I'm working on an iPhone app, and I'm having some compiler trouble. Here's the low-down:
- I am compiling using Xcode 3.2.3, targeting iOS 4.0: my device is a 2nd Gen. iPod touch running iOS 4.0.
- Compiling with GCC 4.2: works on both the simulator and the device
- Compiling with LLVM compiler 1.5: works on simulator, but not on device.
- Compiling with LLVM GCC 4.2: same problem as with LLVM compiler 1.5.
When it fails, the app never even finishes loading. This is what the log looks like:
run
Running…
[Switching to thread 11523]
[Switching to thread 11523]
sharedlibrary apply-load-rules all
continue
Program received signal: “EXC_BAD_ACCESS”.
warning: check_safe_call: could not restore current frame
warning: Unable to restore previously selected frame.
warning: Unable to restore previously selected frame.
warning: Unable to restore previously selected frame.
warning: Unable to restore previously selected frame.
warning: Unable to restore previously selected frame.
I have no idea what is going on with this. I really want to update my code to use the latest features announced at WWDC (implicit @synthesize
, the ability to add instance variables in categories, etc.), but Clang is necessary for that.
回答1:
Looks like something pooped on memory. More specifically, on the stack.
There are some fairly significant, though entirely subtle, differences in code-gen between LLVM and GCC. Keep in mind that LLVM-GCC is really GCC->LLVM; that is, the GCC parser feeding the LLVM code generation engine.
Thus, I suspect you have hit a lovely edge case. Either a bug in LLVM's codegen or a bug in your program that manifests itself as this kind of a crash.
Off the top of my head, I could imagine that a failure to -copy a block and then execute that block on a different thread might manifest as a crash like this.
In any case, file a bug if you can.
来源:https://stackoverflow.com/questions/3278337/compiling-with-llvm-clang-causes-crash-not-gcc-4-2