firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

Crashlytics: crashes in case signal/mach exception happens simultaneous in different threads

Open dkimitsa opened this issue 2 months ago • 5 comments

Description

this ovserved in Java/C#, mostly due https://github.com/firebase/firebase-ios-sdk/issues/15383, but anyway Crashlytics is not handling simultaneous crash events in different threads (or just null pointers exception in try/catch blocks).

Reproducing the issue

simple code to reproduce with java:

Runnable NPE = () -> {
    try {
        ((String) null).equals("hello");
    } catch (NullPointerException ignored) {}
};
Thread t1 = new Thread(NPE);
Thread t2 = new Thread(NPE);
t1.start();
t2.start();

In case of mach handler:

two exception messages will be scheduled and handled by FIRCLSMachExceptionDispatchMessage and crashed in:

static bool FIRCLSMachExceptionRecord(FIRCLSMachExceptionReadContext* context,
                                      MachExceptionMessage* message) {
  ...
  if (FIRCLSContextMarkAndCheckIfCrashed()) {
    FIRCLSSDKLog("Error: aborting mach exception handler because crash has already occurred\n");
    exit(1);       /// <<<<<< CRASH HERE
    return false;
  }
  ...
}

in case of signal handler

FIRCLSSignalHandler will be handled simultaneously in corresponding threads: These will mess signals by running FIRCLSSignalSafeRemoveHandlers/FIRCLSSignalSafeInstallPreexistingHandlers in race conditions and will crash with

static void FIRCLSSignalRecordSignal(int savedErrno, siginfo_t *info, void *uapVoid) {
  if (FIRCLSContextMarkAndCheckIfCrashed()) {
    FIRCLSSDKLog("Error: aborting signal handler because crash has already occurred");
    exit(1);       /// <<<<<< CRASH HERE 
    return;
  }
}  

Firebase SDK Version

12.3

Xcode Version

26.0

Installation Method

Zip

Firebase Product(s)

Crashlytics

Targeted Platforms

iOS

Relevant Log Output


If using Swift Package Manager, the project's Package.resolved

If using CocoaPods, the project's Podfile.lock

No response

dkimitsa avatar Oct 06 '25 08:10 dkimitsa