Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- If you use a narrow string path interface (for instance, `sentry_options_set_database_path()`) on _Windows_ rather than one of the wide string variants (`sentry_options_set_database_pathw()`), then the expected encoding is now UTF-8. ([#1413](https://github.com/getsentry/sentry-native/pull/1413))

**Features**:

- Add an option to use the stack pointer as an upper limit for the stack capture range in `crashpad` on Windows. This is useful for targets like Proton/Wine, where one can't rely on the TEB-derived upper bound being correctly maintained by the system, leading to overly large stack captures per thread. ([#1427](https://github.com/getsentry/sentry-native/pull/1427), [crashpad#137](https://github.com/getsentry/crashpad/pull/137))

**Fixes**:

- Add logs flush on crash. This is not available for macOS with the `crashpad` backend. ([#1404](https://github.com/getsentry/sentry-native/pull/1404))
Expand Down
16 changes: 16 additions & 0 deletions include/sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,22 @@ SENTRY_API void sentry_options_set_system_crash_reporter_enabled(
SENTRY_API void sentry_options_set_crashpad_wait_for_upload(
sentry_options_t *opts, int wait_for_upload);

/**
* Limits stack capture to stack pointer for the Crashpad backend.
* When enabled, Crashpad will use the current stack pointer as the upper bound
* of the stack capture range, once validated to be within TEB
* StackLimit/StackBase values. This reduces the capture range compared to
* using the full TEB-derived stack region.
*
* This is useful when running under Wine/Proton where the TEB values may
* be incorrect, leading to excessively large stack captures. This is
* disabled by default.
*
* This setting only has an effect when using the `crashpad` backend on Windows.
*/
SENTRY_API void sentry_options_set_crashpad_limit_stack_capture_to_sp(
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.
Expand Down
12 changes: 10 additions & 2 deletions src/backends/sentry_backend_crashpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,22 @@ crashpad_backend_startup(
}
#endif

crashpad::CrashpadInfo *crashpad_info
= crashpad::CrashpadInfo::GetCrashpadInfo();

if (!options->system_crash_reporter_enabled) {
// Disable the system crash reporter. Especially on macOS, it takes
// substantial time *after* crashpad has done its job.
crashpad::CrashpadInfo *crashpad_info
= crashpad::CrashpadInfo::GetCrashpadInfo();
crashpad_info->set_system_crash_reporter_forwarding(
crashpad::TriState::kDisabled);
}

if (options->crashpad_limit_stack_capture_to_sp) {
// Enable stack capture limit to work around Wine/Proton TEB issues
crashpad_info->set_limit_stack_capture_to_sp(
crashpad::TriState::kEnabled);
}

return 0;
}

Expand Down
8 changes: 8 additions & 0 deletions src/sentry_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ sentry_options_new(void)
opts->crashpad_wait_for_upload = false;
opts->enable_logging_when_crashed = true;
opts->propagate_traceparent = false;
opts->crashpad_limit_stack_capture_to_sp = 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 @@ -488,6 +489,13 @@ sentry_options_set_crashpad_wait_for_upload(
opts->crashpad_wait_for_upload = !!wait_for_upload;
}

void
sentry_options_set_crashpad_limit_stack_capture_to_sp(
sentry_options_t *opts, int enabled)
{
opts->crashpad_limit_stack_capture_to_sp = !!enabled;
}

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 @@ -44,6 +44,7 @@ struct sentry_options_s {
bool crashpad_wait_for_upload;
bool enable_logging_when_crashed;
bool propagate_traceparent;
bool crashpad_limit_stack_capture_to_sp;

sentry_attachment_t *attachments;
sentry_run_t *run;
Expand Down
Loading