rust-lang / rust-lang/rust

How much stack space should Windows reserve for stack overflow exceptions?

Open
#134,200 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-runtime C-discussion O-windows T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

We reserve some stack space for handling stack overflow exceptions. Our exception handler just prints a stack overflow message along with the thread name. Currently we reserve ~20kb of stack:

https://github.com/rust-lang/rust/blob/903d2976fdb6ceeb65526b7555d8d1e6f8c02134/library/std/src/sys/pal/windows/stack_overflow.rs#L8C59-L8C65

This number is somewhat arbitrary and was chosen over a decade ago, pre-1.0, when Rust was a very different language. That said, we set the main thread to have a stack size of 1mb by default so 20kb is just a few percent of it. Still, sometimes every byte counts and I think it would be useful to have some kind of rationale for the number (e.g. is, say, 4kb not enough?).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with library/std/src/sys/pal/windows/stack_overflow.rs at the current stack reservation. Investigate how Windows stack-overflow exception handling uses that reserved space and what the handler must do. Done means establishing a defensible reservation size and documenting the rationale, or identifying a justified change.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.