Skip to content

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

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

Open
ChrisDenton opened this issue May 14, 2021 · 0 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries C-feature-request Category: A feature request, i.e: not implemented / a PR. O-windows Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ChrisDenton
Copy link
Member

ChrisDenton commented May 14, 2021

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?

@jonas-schievink jonas-schievink added A-linkage Area: linking into static, shared libraries and binaries C-feature-request Category: A feature request, i.e: not implemented / a PR. O-windows Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries C-feature-request Category: A feature request, i.e: not implemented / a PR. O-windows Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants