Closed akonradi closed 1 year ago
If this isn't controversial, I'm happy to work on the environment variable approach.
+1, we just ran into the same issue - the test was short a few tens of bytes. I also pinpointed it to the stack size and then found this issue.
BTW, it's not 4096B, but sizeof(usize) * 4096
, i.e., 32KB on 64-bit platforms. Your test with 0x8000 (i.e., 32KB) is just above the limit.
As a starting point, I think env variable approach would be a sufficient one. But, there is in fact a method Builder::stack_size()
. This is empty for now. Maybe you want to implement it as well to pass the size?
The stack size of spawned threads is determined by the call to
generator::Gn::new
inspawn_threads
: https://github.com/tokio-rs/loom/blob/16e5e9a0e562cf754ced04ac1a82802b8e492178/src/rt/scheduler.rs#L142-L158. Since loom doesn't specify a stack size, thegenerator
crate's default is used, which is ~1000~ 4096 bytes. This isn't enough for code with deeply nested function calls; the result there is a stack overflow.The stack size should be configurable either via environment variables or as an argument when invoking
loom::model
.