Skip to content

Crashlytics AW Sigaction crash fix #6434 #6436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Crashlytics/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- [added] Added stackFrameWithAddress API for recording custom errors that are symbolicated on the backend (#5975).
- [fixed] Fixed comment typos (#6363).
- [fixed] Remove device information from binary image data crash info entries (#6382).
- [fixed] Fixed Apple Watch crash related to sigaction (#6434).

# v4.5.0
- [fixed] Fixed a compiler warning and removed unused networking code (#6210).
Expand Down
2 changes: 2 additions & 0 deletions Crashlytics/Crashlytics/Components/FIRCLSContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ typedef struct {
FIRCLSBinaryImageReadOnlyContext binaryimage;
FIRCLSExceptionReadOnlyContext exception;
FIRCLSHostReadOnlyContext host;
#if CLS_SIGNAL_SUPPORTED
FIRCLSSignalReadContext signal;
#endif
#if CLS_MACH_EXCEPTION_SUPPORTED
FIRCLSMachExceptionReadContext machException;
#endif
Expand Down
2 changes: 2 additions & 0 deletions Crashlytics/Crashlytics/Components/FIRCLSContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,14 @@ bool FIRCLSContextInitialize(FIRCLSInternalReport* report,
});

if (!_firclsContext.readonly->debuggerAttached) {
#if CLS_SIGNAL_SUPPORTED
dispatch_group_async(group, queue, ^{
_firclsContext.readonly->signal.path =
FIRCLSContextAppendToRoot(rootPath, FIRCLSReportSignalFile);

FIRCLSSignalInitialize(&_firclsContext.readonly->signal);
});
#endif

#if CLS_MACH_EXCEPTION_SUPPORTED
dispatch_group_async(group, queue, ^{
Expand Down
2 changes: 2 additions & 0 deletions Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,9 @@ - (void)crashReportingSetupCompleted:(FIRCLSProfileMark)mark {
// check our handlers
FIRCLSDispatchAfter(2.0, dispatch_get_main_queue(), ^{
FIRCLSExceptionCheckHandlers((__bridge void *)(self));
#if CLS_SIGNAL_SUPPORTED
FIRCLSSignalCheckHandlers();
#endif
#if CLS_MACH_EXCEPTION_SUPPORTED
FIRCLSMachExceptionCheckHandlers();
#endif
Expand Down
2 changes: 2 additions & 0 deletions Crashlytics/Crashlytics/Handlers/FIRCLSSignal.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <dlfcn.h>
#include <stdlib.h>

#if CLS_SIGNAL_SUPPORTED
static const int FIRCLSFatalSignals[FIRCLSSignalCount] = {SIGABRT, SIGBUS, SIGFPE, SIGILL,
SIGSEGV, SIGSYS, SIGTRAP};

Expand Down Expand Up @@ -316,3 +317,4 @@ static void FIRCLSSignalHandler(int signal, siginfo_t *info, void *uapVoid) {
// restore errno
errno = savedErrno;
}
#endif
6 changes: 4 additions & 2 deletions Crashlytics/Crashlytics/Handlers/FIRCLSSignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include <signal.h>
#include <stdbool.h>

#define FIRCLSSignalCount (7)

// per man sigaltstack, MINSIGSTKSZ is the minimum *overhead* needed to support
// a signal stack. The actual stack size must be larger. Let's pick the recommended
// size.
Expand All @@ -31,6 +29,9 @@
#define CLS_SIGNAL_HANDLER_STACK_SIZE 0
#endif

#if CLS_SIGNAL_SUPPORTED
#define FIRCLSSignalCount (7)

typedef struct {
const char* path;
struct sigaction originalActions[FIRCLSSignalCount];
Expand All @@ -49,3 +50,4 @@ bool FIRCLSSignalSafeInstallPreexistingHandlers(FIRCLSSignalReadContext* roConte
void FIRCLSSignalNameLookup(int number, int code, const char** name, const char** codeName);

void FIRCLSSignalEnumerateHandledSignals(void (^block)(int idx, int signal));
#endif
1 change: 1 addition & 0 deletions Crashlytics/Crashlytics/Helpers/FIRCLSFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define CLS_USE_SIGALTSTACK (!TARGET_OS_WATCH && !TARGET_OS_TV)
#define CLS_CAN_SUSPEND_THREADS !TARGET_OS_WATCH
#define CLS_MACH_EXCEPTION_SUPPORTED (!TARGET_OS_WATCH && !TARGET_OS_TV)
#define CLS_SIGNAL_SUPPORTED !TARGET_OS_WATCH // As of WatchOS 3, Signal crashes are not supported

#define CLS_COMPACT_UNWINDING_SUPPORTED \
((CLS_CPU_I386 || CLS_CPU_X86_64 || CLS_CPU_ARM64) && CLS_COMPACT_UNWINDED_ENABLED)
Expand Down