iosbuildllvmxcode4

iOS App crashes under 3.1.3 when compiled with LLVM2


I have an iOS app with the following (selected) build settings in XCode 4.0.1:

Under Targets/Build Phases, I have libSystem.B.dylib as Optional (Link Binary With Libraries).

On a 1st gen iPod Touch, I'm getting the following results:

  1. Debug Build, C/C++ Compiler Version = LLVM Compiler 2.0, all OK
  2. Ad Hoc Release Build, C/C++ Compiler Version = GCC 4.2, all OK
  3. Ad Hoc Release Build, C/C++ Compiler Version = LLVM GCC 4.2, all OK
  4. Ad Hoc Release Build, C/C++ Compiler Version = LLVM Compiler 2.0, crash a few seconds after starting.

In case 4., the crash report looks like this:

Incident Identifier: 10B8B9C5-0FA5-4C83-AB13-4C3F59D5962D
CrashReporter Key:   29f7901a33e9b055c9034cd051902ea0c87e61f6
Process:         TPE [1484]
Path:            /var/mobile/Applications/4FA4C8CA-DB5D-4096-8458-C76382E68D02/TPE.app/TPE
Identifier:      TPE
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2011-04-09 17:56:58.188 +1000
OS Version:      iPhone OS 3.1.3 (7E18)
Report Version:  104

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

Thread 0 Crashed:
0   libSystem.B.dylib               0000000000 0 + 0

Thread 1:
0   libSystem.B.dylib               0x00001488 mach_msg_trap + 20
1   libSystem.B.dylib               0x00004064 mach_msg + 60
etc.

The crash happens after a number of routines in my code have executed (I can see console output confirming it).

Does anyone have any ideas what would cause this to work under GCC4.2, but crash under LLVM2?


Solution

  • It's just a wild guess, but there was a compiler bug recently in llvm2 that made our app crash the same way. It only happened in release mode with full optimization and only on older devices (probably a specific processor). We switched back to gcc and everything was fine again. Apple updated their compiler in mean time which "fixes bugs for iOS", but we didn't test it yet.