Skip to content
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
**Features**:

- Add option to attach screenshots on Windows to fatal error events. ([#1170](https://github.com/getsentry/sentry-native/pull/1170))
- Add an option for `Crashpad` on Linux to delay application shutdown until the upload of the crash report in the `crashpad_handler` is complete. This is useful for deployment in `Docker` or `systemd`, where the life cycle of additional processes is bound by the application life cycle. ([#1153](https://github.com/getsentry/sentry-native/pull/1153), [crashpad#121](https://github.com/getsentry/crashpad/pull/121))

## 0.8.2

Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ The example currently supports the following commands:
- `capture-transaction`: Captures a transaction.
- `traces-sampler`: Installs a traces sampler callback function when used alongside `capture-transaction`.


Only on Linux using crashpad:
- `crashpad-wait-for-upload`: Couples application shutdown to complete the upload in the `crashpad_handler`.

Only on Windows using crashpad with its WER handler module:

- `fastfail`: Crashes the application using the `__fastfail` intrinsic directly, thus by-passing SEH.
Expand Down
4 changes: 4 additions & 0 deletions examples/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ main(int argc, char **argv)
sentry_options_set_proxy(options, "socks5://127.0.0.1:1080");
}

if (has_arg(argc, argv, "crashpad-wait-for-upload")) {
sentry_options_set_crashpad_wait_for_upload(options, true);
}

sentry_init(options);

if (!has_arg(argc, argv, "no-setup")) {
Expand Down
13 changes: 11 additions & 2 deletions include/sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -1288,8 +1288,17 @@ SENTRY_API void sentry_options_set_system_crash_reporter_enabled(
sentry_options_t *opts, int enabled);

/**
* Sets the maximum time (in milliseconds) to wait for the asynchronous tasks to
* end on shutdown, before attempting a forced termination.
* Enables a wait for the crash report upload to be finished before shutting
* down. This is disabled by default.
*
* This setting only has an effect when using the `crashpad` backend on Linux.
*/
SENTRY_API void sentry_options_set_crashpad_wait_for_upload(
sentry_options_t *opts, int wait_for_upload);

/**
* Sets the maximum time (in milliseconds) to wait for the asynchronous
* tasks to end on shutdown, before attempting a forced termination.
*/
SENTRY_API void sentry_options_set_shutdown_timeout(
sentry_options_t *opts, uint64_t shutdown_timeout);
Expand Down
3 changes: 2 additions & 1 deletion src/backends/sentry_backend_crashpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,8 @@ crashpad_backend_startup(
bool success = data->client->StartHandler(handler, database, database,
minidump_url ? minidump_url : "", proxy_url, annotations, arguments,
/* restartable */ true,
/* asynchronous_start */ false, attachments, screenshot);
/* asynchronous_start */ false, attachments, screenshot,
options->crashpad_wait_for_upload);
sentry_free(minidump_url);

#ifdef SENTRY_PLATFORM_WINDOWS
Expand Down
8 changes: 8 additions & 0 deletions src/sentry_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ sentry_options_new(void)
opts->auto_session_tracking = true;
opts->system_crash_reporter_enabled = false;
opts->attach_screenshot = false;
opts->crashpad_wait_for_upload = false;
opts->symbolize_stacktraces =
// AIX doesn't have reliable debug IDs for server-side symbolication,
// and the diversity of Android makes it infeasible to have access to debug
Expand Down Expand Up @@ -452,6 +453,13 @@ sentry_options_set_system_crash_reporter_enabled(
opts->system_crash_reporter_enabled = !!enabled;
}

void
sentry_options_set_crashpad_wait_for_upload(
sentry_options_t *opts, int wait_for_upload)
{
opts->crashpad_wait_for_upload = !!wait_for_upload;
}

void
sentry_options_set_shutdown_timeout(
sentry_options_t *opts, uint64_t shutdown_timeout)
Expand Down
1 change: 1 addition & 0 deletions src/sentry_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct sentry_options_s {
bool symbolize_stacktraces;
bool system_crash_reporter_enabled;
bool attach_screenshot;
bool crashpad_wait_for_upload;

sentry_attachment_t *attachments;
sentry_run_t *run;
Expand Down
3 changes: 2 additions & 1 deletion tests/test_integration_crashpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,8 @@ def test_disable_backend(cmake, httpserver):


@pytest.mark.skipif(
sys.platform != "darwin", reason="retry mechanism test only runs on macOS"
sys.platform != "darwin" or not os.getenv("CI"),
reason="retry mechanism test only runs on macOS in CI",
)
def test_crashpad_retry(cmake, httpserver):
tmp_path = cmake(["sentry_example"], {"SENTRY_BACKEND": "crashpad"})
Expand Down
Loading