From 54567efda7c08d04383001456976f0f2e43bbfbd Mon Sep 17 00:00:00 2001 From: Sean Linsley Date: Thu, 16 Mar 2023 11:07:42 -0500 Subject: [PATCH 1/2] Clarify that RUST_MIN_STACK is internally cached For larger applications it's important that users set `RUST_MIN_STACK` at the start of their program because `min_stack` caches the value. Not doing so can lead to their `env::set_var` call surprisingly not having any effect. --- library/std/src/thread/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index b9aaf5f6e15db..ff65c00483d7e 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -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. Also, note +//! that `RUST_MIN_STACK` is cached internally so should be set before any threads are started. //! //! Note that the stack size of the main thread is *not* determined by Rust. //! From 6eef755012a0f1ac0c40148b7135a125e512f6f0 Mon Sep 17 00:00:00 2001 From: Sean Linsley Date: Fri, 17 Mar 2023 09:12:54 -0500 Subject: [PATCH 2/2] Update mod.rs --- library/std/src/thread/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index ff65c00483d7e..13b845b25c92d 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -131,8 +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. Also, note -//! that `RUST_MIN_STACK` is cached internally so should be set before any threads are started. +//! 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. //!