Crashes on 32 bit after Xcode 11.4

Is anyone else seeing crashes on 32 bit devices (iOS 10 or earlier) after updating to Xcode 11.4? After releasing to the App Store we say tons of crash-on-launch bugs with stack traces in the Branch SDK and Firebase SDK. I suspect it is a compiler change because I hadn't updated either SDK for a few releases.

There is more investigation happening on this github issue, I was just curious if anyone else has run into it.

7 Likes

I got an iPad 2 today to repro the crashes. I see a different crash trace than Crashlytics was reporting (perhaps this is a hard one for Crashlytics to capture - I noticed that there were 100+ different crash sites being reported and none of them has "crash reason" set.) It only repros when using a Release build profile.

This is the crash trace. It looks like somehow the pc gets pointed at 0x0 while looking up some Swift metadata.

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
* frame #0: 0x00000000
frame #1: 0x013b2f70 libswiftCore.dylib`SingletonMetadata + 24
frame #2: 0x0139f9d4 libswiftCore.dylib`__SwiftNativeNSError + 20
frame #3: 0x0139f9e8 libswiftCore.dylib`_TtCs12_SwiftObject + 20
frame #4: 0x0139f9d4 libswiftCore.dylib`__SwiftNativeNSError + 20

Here is a bug to track the issue: [SR-12511] Swift 5.2 / Xcode 11.4 apps crash on 32 bit devices in SingletonMetadata · Issue #54953 · apple/swift · GitHub

The fact that Xcode 11.4 does not support building 32-bit applications any more may be the problem.

That’s not true though.

2 Likes

The same for me, after updating to Xcode 11.4, my app crashes on 32 bits devices.
It appears to be related to the Swift compiler optimization level. If the level is anything other than -Onone, it crashes on startup with EXC_BAD_ACCESS...

1 Like

We also got this issue after upgrading to Xcode 11.4 - app crashing on 32-bit devices with stack trace similar to the one OP posted.

Same here. I've reported the crash here: [SR-12555] Xcode 11.4 / Swift 5.2 makes app crash during launch on 32-bit devices · Issue #54999 · apple/swift · GitHub (Although maybe it's more relevant to file a bug on https://feedbackassistant.apple.com)

We are getting this exact same problem in our medical app. The crash is happening to old devices (as same as iPhone 5). The project has been compiled using Xcode 11.4.

I figure out the real reason.

After lots of work such as log and instruction debugging, I am surely it's a bug xcode 11.4 swift compiler optimization. Detailly, the optimization cause a stack pointer (fp) at the point opening a new function stack frame. I show it in the following.

Refer to this

3 Likes

As far as I can see Xcode 11.4.1 does NOT fix this problem.

Good to see this thread. I've spent lots of time debugging on a 32-bit device and found this pattern: reducing number of properties in an offending class/struct helps. It's a kind of anecdotal but deleting some properties seemed to have helped in my case.

class OffendingClass {
    
    let one: ClassA
    let two: ClassB
    let three: ClassC
    let four: StructA
    let five: StructB? // deleting this property makes it work

   init(one: ClassA, two: ClassB, three: ClassC, four: StructA, five: StructB?)  {
       self.one = one
       self.two = two
       self.three = three
       self.four = four
       self.five = five
   }
}

This seems to be consistent with the stack corruption as described by @victor-c
It takes time to find offending class/struct but once you have located it, it's getting pretty obvious that some of its property access results in an exception. In some cases code refactoring may help avoid this broken compiler optimization.

Xcode 11.5 beta notes that it fixes an issue on 32 bit processors, you could give it a try and see if it fixes your issue.

1 Like

And if you don't want to use a beta, I've seen several reports that going back to Xcode 11.3.1 also resolves the issue.

Have tried 11.5 beta and, yes, it seems that the bug has been resolved there. Will be testing some more.

Have tried 11.5 release version and so far so good.

2 Likes

Just tried Xcode 11.5 on stable channel and worked like a charm, fix confirmed

1 Like