<compiler-generated> Error shows fatal crash in firebase crashlytics...but the app does not crash for the user

getting a <compiler-generated> Crash in crashlytics. However, the user's app on the device does NOT actually crash. Everything works as expected.

Heres is the stack trace: Crashed: com.apple.main-thread 0 DigiDeals 0x33404 specialized Universal.displayMessages() + 4302730244 (<compiler-generated>:4302730244) 1 DigiDeals 0x32840 specialized Universal.displayMessages() + 453 (Universal.swift:453) 2 libswift_Concurrency.dylib 0x4d764 swift::runJobInEstablishedExecutorContext(swift::Job*) + 436 3 libswift_Concurrency.dylib 0x4e9c8 swift_job_runImpl(swift::Job*, swift::ExecutorRef) + 72 4 libdispatch.dylib 0x124b4 _dispatch_main_queue_drain + 748 5 libdispatch.dylib 0x121b8 _dispatch_main_queue_callback_4CF + 44 6 CoreFoundation 0x56710 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16 7 CoreFoundation 0x53914 __CFRunLoopRun + 1996 8 CoreFoundation 0x52cd8 CFRunLoopRunSpecific + 608 9 GraphicsServices 0x11a8 GSEventRunModal + 164 10 UIKitCore 0x40a90c -[UIApplication _run] + 888 11 UIKitCore 0x4be9d0 UIApplicationMain + 340 12 UIKitCore 0x638384 keypath_get_selector_hoverStyle + 11024 13 DigiDeals 0x4aaf8 main + 4302826232 (AppDelegate.swift:4302826232) 14 ??? 0x1c2bd5e4c (Missing)

Answered by DTS Engineer in 796820022
the app never crashed on the device

Oh, it most certainly did |-:

It’s possible that the user didn’t notice this crash because the app was in the background at the time, but there’s clear evidence of a crash here. Consider this

Exception Type:  EXC_BREAKPOINT (SIGTRAP)

This usually mean that your app trapped, that is, detected a failure case and crashed itself. Typically this comes from the Swift runtime, for example, when you force unwrap an optional that’s nil or access an array out of bounds.

The crashing thread backtrace is this:

Thread 0 Crashed:
0 DigiDeals                  … 0x100994000 + 209924
1 DigiDeals                  … 0x100994000 + 303489
2 DigiDeals                  … 0x100994000 + 307013
3 DigiDeals                  … 0x100994000 + 350045
4 DigiDeals                  … 0x100994000 + 307369
5 libswift_Concurrency.dylib … completeTaskWithClosure(swift::AsyncContext…

It’s hard to say where this crash came from because frames 4 through 0 are not symbolicated. I recommend that you symbolicate the crash report to determine the identity of the crashing code. See Adding identifiable symbol names to a crash report.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

It’s hard to say what’s going on here based on a snippet of your carsh report. Please post a full Apple crash report, per the advice in Posting a Crash Report.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Not sure if this is the necessary file because the app never crashed on the device... but the time matches. This is from my phone.

the app never crashed on the device

Oh, it most certainly did |-:

It’s possible that the user didn’t notice this crash because the app was in the background at the time, but there’s clear evidence of a crash here. Consider this

Exception Type:  EXC_BREAKPOINT (SIGTRAP)

This usually mean that your app trapped, that is, detected a failure case and crashed itself. Typically this comes from the Swift runtime, for example, when you force unwrap an optional that’s nil or access an array out of bounds.

The crashing thread backtrace is this:

Thread 0 Crashed:
0 DigiDeals                  … 0x100994000 + 209924
1 DigiDeals                  … 0x100994000 + 303489
2 DigiDeals                  … 0x100994000 + 307013
3 DigiDeals                  … 0x100994000 + 350045
4 DigiDeals                  … 0x100994000 + 307369
5 libswift_Concurrency.dylib … completeTaskWithClosure(swift::AsyncContext…

It’s hard to say where this crash came from because frames 4 through 0 are not symbolicated. I recommend that you symbolicate the crash report to determine the identity of the crashing code. See Adding identifiable symbol names to a crash report.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thank you so much for your replies. I really do appreciate it. I will work on symblocating. This particular crash is from my phone. And the app is working from my perspective looking at the device as it should. The app never shut down that I could see. I was able to do everything even after the crash. I'm not trying to be argumentative and I apologize if I appear to be. But that's what I see. I think the alert that pops up when the app is opened for the very first time after downloading the app. Thank you again for all of your help

Here is a symbolicated file

this is the code in AppDelegate didFinishLaunchingWithOptions that calls displayMessages which is where the app seems to crash

Task{      
             await universal.displayMessages()
        }

this is the displayMessages() code with the line it seems to crash at in bold. Again, the alert shows and when OK is selected (only when app is first opened after download otherwise the app just goes to the home screen when OK is selected) the popUpZipCode() (underlined below) runs. The app seems to crash only when the app first runs after download.

func displayMessages() async{
        var inf: Information = Information(Message: " ", MsgType: " ")
        var buttonText: String = "OK"
        //if (!msgDisp && allowNotifications){
        if (!msgDisp){
            do {
                let querySnapshot = try await db.collection("AppInfo").getDocuments()
                for document in querySnapshot.documents {
                    //print("\(document.documentID) => \(document.data())") ///// your code
                    if (document["MsgType"] as! String == "I"){
                        inf.Message = document["Message"] as! String
                        inf.MsgType = document["MsgType"] as! String
                        information.append(inf)
                    } else if (document["MsgType"] as! String == "B"){
                        buttonText = document["Message"] as! String
                    } else if (document["MsgType"] as! String == "Z"){
                        zipMsg = document["Message"] as! String
                    } else if (document["MsgType"] as! String == "V"){
                        curVers = document["Message"] as! String
                        let appVersion = Bundle.main.releaseVersionNumber
                        if (curVers != appVersion){
                            needUpdate = true
                            inf.Message = "DigiD has a more current version. Select Update App below to update Digid"
                            inf.MsgType = "I"
                            information.append(inf)
                        } else {
                            needUpdate = false
                        }
                    }
                }
                // show if allowNotifications OR needUpdate
                if (information.count > 0 && (allowNotifications || needUpdate)) {
                    var msg: String = " "
                    for m in information{
                        msg = msg + "\(m.Message)\n\n"
                    }
                    let topController = topMostController()
                    
                    let alert = UIAlertController(title: "DigiDeals Info", message: msg, preferredStyle: .alert)
                    //initialRun = true //for testing
                    alert.addAction(UIAlertAction(title: buttonText, style: .cancel, handler: { (action: UIAlertAction!) in
                       if (initialRun){
                            initialRun = false
                            __universal.popUpZipCode()__
                        }
                        //universal.showZipAlert(topController: topController!)
                    }))
                    
                    if (needUpdate){
                        alert.addAction(UIAlertAction(title: "Update App", style: .default, handler: { (action: UIAlertAction!) in
                            if let url = URL(string: "itms-apps://apps.apple.com/us/app/digidealsus/id6499593438") {
                                UIApplication.shared.open(url)
                            }
                            //universal.showZipAlert(topController: topController!)
                        }))
                    }
                   ** topController!.present(alert, animated: true)**

                }
            } catch {
                print("Error getting documents: \(error)")
            }
        }

Hey hey, we’re making progress!

Note that your app has a third-party crash reporter in play (per frame 8 of your latest crash report). It’s possible that this is disrupting the Apple crash reporter. I talk about this in depth in Implementing Your Own Crash Reporter. IMO you’d be better off removing that.

However, the crash report itself seems reasonable enough so let’s assume it’s good. And that means this:

Thread 0 Crashed:
0   DigiDeals … specialized Universal.displayMessages() (in DigiDeals) (Universal.swift:469) + 209924

That’s flagging line 469 of Universal.swift. I presume that’s the line you highlighted in (not actually :-) bold. If so, the most obvious potential cause for that trap is the force unwrap of topController. You’ll have to trace through the logic of your topMostController() routine to find out why it’s returning nil.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thank you again for all of your help. I am checking for nil on the topController so I hope this will fix the issue. I still find it odd that the app did not crash on the devices...at least the app didn't shut down as in a normal crash. But hopefully this will get the crashes to stop showing up in crashlytics. I learned a lot from you on this thread so thanks a ton!

&lt;compiler-generated&gt; Error shows fatal crash in firebase crashlytics...but the app does not crash for the user
 
 
Q