Skip to content

On Windows the maximum size of the main thread's stack should at least match that of new threads #85303

@ChrisDenton

Description

@ChrisDenton

On Windows an area of virtual memory is reserved for the main thread's stack to grow in to. The size of this area is requested by the application via the binary's header. Currently Rust does not set the size of this reserved area so instead the linker uses a fallback value (often only 1 MiB).

I think Rust should set the maximum stack size to at least match the default size for new threads (if not larger). This can be done via linker flags. E.g. reserving 16 MiB of virtual memory for stack space is done using /STACK argument on MSVC:

/STACK:16777216

And on Mingw it's --stack:

-Wl,--stack,16777216

However, if Rust does set the stack size it would need a way to override this value. Perhaps via a -C codegen option?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesC-feature-requestCategory: A feature request, i.e: not implemented / a PR.O-windowsOperating system: WindowsT-compilerRelevant to the compiler 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