Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add SIGTERM support #3895

Merged
merged 9 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 8.25.0

- Add SIGTERM support ([#3895](https://github.com/getsentry/sentry-cocoa/pull/3895))

Check failure on line 5 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / danger / danger

The changelog entry seems to be part of an already released section `## 8.25.0`. Consider moving the entry to the `## Unreleased` section, please.

Check failure on line 5 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / danger / danger

The changelog entry seems to be part of an already released section `## 8.25.0`. Consider moving the entry to the `## Unreleased` section, please.

Check failure on line 5 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / danger / danger

The changelog entry seems to be part of an already released section `## 8.25.0`. Consider moving the entry to the `## Unreleased` section, please.

### Features

- Add Session Replay, which is **still experimental**. (#3625)
Expand Down
11 changes: 10 additions & 1 deletion Sources/SentryCrash/Recording/SentryCrashDoctor.m
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@
return NO;
}

- (BOOL)wasProgramTerminationRequested:(NSDictionary *)errorReport
{
return [(errorReport[@SentryCrashField_Signal][@SentryCrashField_Signal]) intValue] == SIGTERM;
naftaly marked this conversation as resolved.
Show resolved Hide resolved
}

- (SentryCrashDoctorFunctionCall *)lastFunctionCall:(NSDictionary *)report
{
SentryCrashDoctorFunctionCall *function = [[SentryCrashDoctorFunctionCall alloc] init];
Expand Down Expand Up @@ -471,7 +476,11 @@
(void *)address];
}
}


if ([self wasProgramTerminationRequested:errorReport]) {
return @"Graceful OS termination requested.";

Check warning on line 481 in Sources/SentryCrash/Recording/SentryCrashDoctor.m

View check run for this annotation

Codecov / codecov/patch

Sources/SentryCrash/Recording/SentryCrashDoctor.m#L481

Added line #L481 was not covered by tests
}

return nil;
} @catch (NSException *e) {
NSArray *symbols = [e callStackSymbols];
Expand Down
12 changes: 11 additions & 1 deletion Sources/SentryCrash/Recording/Tools/SentryCrashSignalInfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ static const SentryCrashSignalInfo g_fatalSignalData[] = {
SIGNAL_INFO_NOCODES(SIGPIPE),
SIGNAL_INFO(SIGSEGV, g_sigSegVCodes),
SIGNAL_INFO_NOCODES(SIGSYS),
SIGNAL_INFO(SIGTERM, g_sigTrapCodes),
SIGNAL_INFO(SIGTRAP, g_sigTrapCodes),
SIGNAL_INFO_NOCODES(SIGTERM),
};
static const int g_fatalSignalsCount = sizeof(g_fatalSignalData) / sizeof(*g_fatalSignalData);

Expand All @@ -130,6 +131,15 @@ static const int g_fatalSignals[] = {
SIGSEGV,
SIGSYS,
SIGTRAP,

// SIGTERM can be caught and is usually sent by iOS and variants
// when Apple wants to try and gracefully shutdown the app
// before sending a SIGKILL (which can't be caught).
// Some areas I've seen this happen are:
// - When the OS updates an app.
// - In some circumstances for Watchdog Events.
// - Resource overuse (CPU, Disk, ...).
SIGTERM,
};

const char *
Expand Down
Loading