Conversation
Rust spawns threads with a 2 MiB stack; the Linux main thread gets 8 MiB. The bootstrap runtime raises this for the server, but test runtimes are built by the tokio test macro and keep the default, so debug-profile runs of the native and wire suites abort with "thread ... has overflowed its stack" (2 MiB: 6/7 abort; 4 MiB and above: clean). Set RUST_MIN_STACK for every process cargo runs, so a local run needs no exported environment variable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Rust gives spawned threads a 2 MiB stack; the Linux main thread gets 8 MiB. The bootstrap runtime already raises this for the server, but the runtimes the test macros build keep the default, so debug-profile runs of the native suite abort with
thread ... has overflowed its stack:RUST_MIN_STACKnative_error_code_classificationCI passes at the default because the
ciprofile has smaller frames; this change is for the debug profile every contributor runs locally.What changed
.cargo/config.toml(new):[env] RUST_MIN_STACK = "8388608"— every process cargo runs gets the main-thread size, socargo test,cargo nextest runandcargo runbehave the same without an exported variable.The file is added with
git add -f:.cargo/is gitignored in this repository, and this is a config file's intended home (it changes no source and no dependency).Platform
Tested on Linux (x86_64): the main thread gets an 8 MiB stack (
ulimit -s), while Rust spawns its own threads with 2 MiB — the mismatch the change removes. The abort ladder above was measured with a debug build on that host; CI'sciprofile already fits the default. The setting is a floor for cargo-run processes, so other platforms keep their own defaults when it is not the binding limit.Steps to test
env -u RUST_MIN_STACK cargo nextest run -p nodedb --test native -E 'test(native_error_code_classification)'→ 7 passedenv -u RUST_MIN_STACK cargo nextest run -p nodedb --test native -E 'test(vector_search_serializes_distance)'→ 1 passedWithout the change, both abort at the default stack on a debug build.
Behaviour changes
None in the product. The change raises the stack floor for the processes cargo runs (tests,
cargo run); no query path changes.No issue to close: the stack default is the task.