user1002430
user1002430

Reputation:

How to increase stack size of threads used by `cargo test`?

I have a program that uses a large amount of stack. I use Linux, and so have already set the stack size limit via ulimit -s 1048576.

Running cargo test -- --test-threads 1 works as expected, but when I use more than one thread, e.g. cargo test -- --test-threads 2, I get fatal runtime error: stack overflow. I believe this is because the Rust thread default stack size, used when running tests, is too small.

How do I increase this stack size when running cargo test?

Upvotes: 2

Views: 3084

Answers (2)

Bhavik Limani
Bhavik Limani

Reputation: 479

You can use stacker to increase the size of the stack dynamically.

Upvotes: 1

user1002430
user1002430

Reputation:

Found it: RUST_MIN_STACK, as in RUST_MIN_STACK=104857600 cargo test.

Upvotes: 7

Related Questions