-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Setting a lower RUST_MIN_STACK
than DEFAULT_STACK_SIZE
increases stack???
#126897
Comments
The default stack size of new threads is 2 MiB. However, the default stack size of the main thread varies depending on the platform and possibly platform-dependent build configuration. |
Rust does not override every last platform-specific behavior. To do so would likely be quite harmful. |
Actually, wait. I'm confused. For rustc, this shouldn't matter because of the DEFAULT_STACK_SIZE (not to be confused with the default stack size). |
@biabbas What version of rustc did you test with? |
No repro on x86_64-unknown-linux-gnu. |
Wait, I misapplied some directions. It... does repro? What. |
RUST_MIN_STACK
than DEFAULT_STACK_SIZE
increases stack???
I was able to reproduce this behavior on rust 1.75, 1.78, 1.79 stable. |
You are right, default stack size for new threads is 2mb. I went through the std thread code and I see that min_stack uses this RUST_MIN_STACK variable to influence the size of thread builder stack size. In the test case what stack is overflowed and why RUST_MIN_STACK workaround fixes it? |
Could you please elaborate and differentiate between the two. |
@biabbas |
Can rustc be using parallelism( sub threads with limit around 2mb) for program compilation? In that case the error message should emit the actual stack that is overflowed. I know cargo uses parallelism for build but not sure if rustc also uses this. I had access to reproduce and work on #113612. This example would compile with RUST_MIN_STACT set to 3mb. |
Yes, we deliberately set the stack size by spawning a thread. However, I would expect we are setting it to 8MB. We emit a suggestion that suggests setting |
While working on this issue #122357, I found that setting the RUST_MIN_STACK variable size to 7mb or more, the build is successful. But the default stack size in rust is 8mb. Why do we have to set RUST_MIN_STACK again for this to work?
Steps to create the example directory are in this link #122357 (comment)
To verify this please follow these steps.
cargo build
in the example, this time the build would fail.RUST_MIN_STACK=$((7*1024*1024)
and runcargo build
again. This time the build is successful.The text was updated successfully, but these errors were encountered: