Skip to content

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

@dkimitsa

Description

@dkimitsa

Description

this ovserved in Java/C#, mostly due #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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions