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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrease SetThreadStackGuarantee value #1044

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- Decrease SetThreadStackGuarantee value ([#1044](https://github.com/getsentry/sentry-native/pull/1044))

## 0.7.10

**Fixes**:
Expand Down
2 changes: 1 addition & 1 deletion src/backends/sentry_backend_crashpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ crashpad_backend_startup(
}
}

#ifdef SENTRY_PLATFORM_WINDOWS
#if defined(SENTRY_PLATFORM_WINDOWS) && !defined(SENTRY_BUILD_SHARED)
sentry__reserve_thread_stack();
#endif

Expand Down
16 changes: 11 additions & 5 deletions src/sentry_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,18 @@ sentry__get_os_context(void)
void
sentry__reserve_thread_stack(void)
{
const unsigned long expected_stack_size = 64 * 1024;
const unsigned long page_size = 4 * 1024;
// 1 page for possible guard region
// 1 page for OS kernel32!RaiseException
// 1 page for possible debug infrastructure
// 1 page for handler
const unsigned long expected_stack_size = 4 * page_size;
unsigned long stack_size = 0;
SetThreadStackGuarantee(&stack_size);
if (stack_size < expected_stack_size) {
stack_size = expected_stack_size;
SetThreadStackGuarantee(&stack_size);
if (SetThreadStackGuarantee(&stack_size)) {
if (stack_size < expected_stack_size) {
stack_size = expected_stack_size;
SetThreadStackGuarantee(&stack_size);
}
}
}

Expand Down
Loading