Hi!
While attempting to diagnose Call stack exhaustion (overflow) in parser with a very large generated file · Issue #128422 · rust-lang/rust · GitHub, one of the issues that came up was that it is impossible to control stacker's segment sizes via the environment.
Typically, stack sizes can be controlled via the RUST_MIN_STACK
environment variable, but that doesn't work for the stacker-based stacks that rustc creates. The code that invokes stacker is here, and it currently hardcodes a 1MiB stack size. The ability to set a larger stack size would have made it possible to work around the issue in #128422.
Would it make sense to have an environment variable for this? There are a few possible directions. Here's two options that came to mind:
- If
RUST_MIN_STACK
is set, create stack segments with sizemax(1MiB, RUST_MIN_STACK)
. I think generally speaking, ifRUST_MIN_STACK
is set in the environment, there's probably some kind of stack exhaustion that's being worked around. This is the most obvious way to do it I think. - Have a separate environment variable. The environment variable doesn't have to be documented -- even if it just exists in source code, enterprising folks will be able to find it.