Skip to content

Commit

Permalink
Rollup merge of #109225 - seanlinsley:patch-1, r=ChrisDenton
Browse files Browse the repository at this point in the history
Clarify that RUST_MIN_STACK may be internally cached

For larger applications it's important that users set `RUST_MIN_STACK` at the start of their program because [`min_stack`](https://github.com/rust-lang/rust/blob/7d3e03666a93bd2b0f78b3933f9305832af771a5/library/std/src/sys_common/thread.rs) caches the value. Not doing so can lead to their `env::set_var` call surprisingly not having any effect.

In my own testing `RUST_MIN_STACK` had no effect until I moved it to the top of `main()`. Hopefully this clarification in the docs will help others going forward.
  • Loading branch information
matthiaskrgr authored Apr 14, 2023
2 parents d558796 + 6eef755 commit ec08676
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion library/std/src/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@
//!
//! * Build the thread with [`Builder`] and pass the desired stack size to [`Builder::stack_size`].
//! * Set the `RUST_MIN_STACK` environment variable to an integer representing the desired stack
//! size (in bytes). Note that setting [`Builder::stack_size`] will override this.
//! size (in bytes). Note that setting [`Builder::stack_size`] will override this. Be aware that
//! changes to `RUST_MIN_STACK` may be ignored after program start.
//!
//! Note that the stack size of the main thread is *not* determined by Rust.
//!
Expand Down

0 comments on commit ec08676

Please sign in to comment.