Skip to content

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

Open
@ChrisDenton

Description

@ChrisDenton

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?).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-discussionCategory: Discussion or questions that doesn't represent real issues.O-windowsOperating system: WindowsT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions