Skip to content

Increase crash handler thread stack guarantee to 128 KiB on Windows - #1500

Merged
tustanivsky merged 5 commits into
mainfrom
chore/win-handler-stack-guarantee-128
Jul 28, 2026
Merged

Increase crash handler thread stack guarantee to 128 KiB on Windows#1500
tustanivsky merged 5 commits into
mainfrom
chore/win-handler-stack-guarantee-128

Conversation

@tustanivsky

@tustanivsky tustanivsky commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

This PR sets SENTRY_HANDLER_STACK_SIZE=128 for the Windows sentry-native builds (x64 and ARM64, both Crashpad and Native backends), doubling the thread stack guarantee for the crash handler from the upstream 64 KiB default. This is done to improve the reliability of stack-overflow crash capturing by giving the crash handler more stack headroom to run after EXCEPTION_STACK_OVERFLOW error is raised.

Why 128 KiB:

  • The upstream 64 KiB default is calibrated for the 1 MB default Windows thread stack, where a larger guarantee would be a significant fraction of the total. Unreal links the game thread with a 12 MB stack (/STACK:12000000), so 128 KiB is ~1% of headroom and costs no additional committed memory - the overflow exception simply fires 128 KiB earlier within the reserve.
  • The extra headroom matters most for the Native backend, whose in-process exception filter does substantially more work on the crashing thread than Crashpad's client-side filter.
  • The factor-10 eligibility check scales with the value: a 128 KiB guarantee requires a >=1.28 MB thread stack reserve, which Unreal threads easily satisfy.

Related Items

Build the Windows sentry-native binaries (x64 and ARM64, Crashpad and
Native backends) with SENTRY_HANDLER_STACK_SIZE=128, doubling the
upstream 64 KiB default. The guarantee is the stack region kept usable
for the in-process exception handler when a thread crashes with a stack
overflow; extra headroom matters most for the Native backend, whose
in-process filter does substantially more work on the crashing thread.

The upstream default is calibrated for the 1 MB default Windows thread
stack, while Unreal links the game thread with a 12 MB stack, so the
larger guarantee costs ~1% of stack headroom and no additional committed
memory. The factor-10 eligibility check now requires a 1.28 MB stack
reserve, which Unreal threads easily satisfy. The value remains
overridable at runtime via the SENTRY_HANDLER_STACK_SIZE env var.
@tustanivsky tustanivsky changed the title fix: Increase crash handler thread stack guarantee to 128 KiB on Windows Increase crash handler thread stack guarantee to 128 KiB on Windows Jul 28, 2026
@tustanivsky
tustanivsky merged commit f189c3a into main Jul 28, 2026
74 of 77 checks passed
@tustanivsky
tustanivsky deleted the chore/win-handler-stack-guarantee-128 branch July 28, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants