Facebook-ios-sdk: FBSDKCrashHandler overwrite the old signal handler of my crash report framework

Created on 19 Oct 2020  路  3Comments  路  Source: facebook/facebook-ios-sdk

if my signal handler register before this code, the handler will be overwrite and will never receive the signal again.

+ (void)installSignalHandler
{
  [self printSigHandler];
  signal(SIGBUS, FBSDKSignalHandler);
  signal(SIGFPE, FBSDKSignalHandler);
  signal(SIGILL, FBSDKSignalHandler);
  signal(SIGPIPE, FBSDKSignalHandler);
  signal(SIGSEGV, FBSDKSignalHandler);
  signal(SIGSYS, FBSDKSignalHandler);
}

the reason seems that FB signal handler doesn't send the signal to the old one.

void FBSDKSignalHandler(int sig)
{
  NSMutableArray<NSString *> *callStack = [[NSThread callStackSymbols] mutableCopy];
  if (callStack) {
    NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 2)];
    if (callStack.count > 2 && [callStack objectsAtIndexes:indexSet]) {
      [callStack removeObjectsAtIndexes:indexSet];
    }
  }
  [FBSDKCrashHandler saveSignal:sig withCallStack:callStack];

  // reset to default handler
  signal(sig, SIG_DFL);
  // re-signal to default handler
  raise(sig);
}

Most helpful comment

We have released v8.2.0. We removed signal handler in this version. Please upgrade your SDK. Thanks!

All 3 comments

Same here.
One quick suggestion:
The int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact); function has third parameter returns the old handling function's pointer. When overriding the signal handler, it should store the old one and

After calling
[FBSDKCrashHandler saveSignal:sig withCallStack:callStack];

call the old handler

Same here.
It is recommended to provide a public function for developers to disable it.

We have released v8.2.0. We removed signal handler in this version. Please upgrade your SDK. Thanks!

Was this page helpful?
0 / 5 - 0 ratings