diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c19b1d5f..c9fe13282 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ **Features**: - Add `SENTRY_SDK_VERSION_MAJOR`, `SENTRY_SDK_VERSION_MINOR`, `SENTRY_SDK_VERSION_PATCH`, and `SENTRY_SDK_VERSION_AT_LEAST` for compile-time version checks. ([#2136](https://github.com/getsentry/sentry-native/pull/2136)) +- Add an option to limit non-crashing thread stack capture size in `crashpad` on Linux. ([#2137](https://github.com/getsentry/sentry-native/pull/2137), [crashpad#172](https://github.com/getsentry/crashpad/pull/172)) ## 0.17.1 diff --git a/external/crashpad b/external/crashpad index 000e3ad7a..89893f495 160000 --- a/external/crashpad +++ b/external/crashpad @@ -1 +1 @@ -Subproject commit 000e3ad7a51c89e49bc00eca9846aa0485cccc96 +Subproject commit 89893f49556b35be7479db412101445a5d221221 diff --git a/include/sentry.h b/include/sentry.h index f12916d6a..af3d16e81 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -2377,6 +2377,15 @@ SENTRY_API void sentry_options_set_crashpad_wait_for_upload( SENTRY_API void sentry_options_set_crashpad_limit_stack_capture_to_sp( sentry_options_t *opts, int enabled); +/** + * Sets the maximum stack capture size for non-crashing threads. + * A value of `0` disables the limit. 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_max_stack_capture_size( + sentry_options_t *opts, uint32_t max_stack_capture_size); + /** * Sets the maximum time (in milliseconds) to wait for the asynchronous * tasks to end on shutdown before attempting a forced termination. diff --git a/src/backends/sentry_backend_crashpad.cpp b/src/backends/sentry_backend_crashpad.cpp index f99b48791..06e83e6f7 100644 --- a/src/backends/sentry_backend_crashpad.cpp +++ b/src/backends/sentry_backend_crashpad.cpp @@ -1192,6 +1192,11 @@ crashpad_backend_startup( crashpad::TriState::kEnabled); } + if (options->crashpad_max_stack_capture_size) { + crashpad_info->set_max_stack_capture_size( + options->crashpad_max_stack_capture_size); + } + #if defined(SENTRY_PLATFORM_WINDOWS) || defined(SENTRY_PLATFORM_LINUX) \ || defined(SENTRY_PLATFORM_MACOS) sentry_scope_observer_t *observer = sentry__scope_observer_new(); diff --git a/src/sentry_options.c b/src/sentry_options.c index 3cac39b3e..acb717ef6 100644 --- a/src/sentry_options.c +++ b/src/sentry_options.c @@ -90,6 +90,7 @@ sentry_options_new(void) opts->propagate_traceparent = false; opts->strict_trace_continuation = false; opts->crashpad_limit_stack_capture_to_sp = false; + opts->crashpad_max_stack_capture_size = 0; opts->cache_keep = SENTRY_CACHE_KEEP_NONE; opts->cache_max_age = 0; opts->cache_max_size = 0; @@ -755,6 +756,13 @@ sentry_options_set_crashpad_limit_stack_capture_to_sp( opts->crashpad_limit_stack_capture_to_sp = !!enabled; } +void +sentry_options_set_crashpad_max_stack_capture_size( + sentry_options_t *opts, uint32_t max_stack_capture_size) +{ + opts->crashpad_max_stack_capture_size = max_stack_capture_size; +} + void sentry_options_set_shutdown_timeout( sentry_options_t *opts, uint64_t shutdown_timeout) diff --git a/src/sentry_options.h b/src/sentry_options.h index 43e58b60a..11e99e412 100644 --- a/src/sentry_options.h +++ b/src/sentry_options.h @@ -54,6 +54,7 @@ struct sentry_options_s { bool propagate_traceparent; bool strict_trace_continuation; bool crashpad_limit_stack_capture_to_sp; + uint32_t crashpad_max_stack_capture_size; sentry_cache_keep_t cache_keep; time_t cache_max_age;