Closed Rdna123 closed 3 years ago
Different O/S and architecture have different setups for the stack, and it is hard to predict how many levels of function calls will overflow the stack. Rhai has a set of defaults (different for debug vs release builds) that are chosen to be reasonable, but may not be accurate for all systems.
Rust's debug build supports only a small number of recursive function calls before overflowing the stack.
You can try compiling with release to do much better. It definitely will not overflow with only 28 levels.
And you can use the Engine::set_max_call_levels
API to restrict the number of recursive function calls. Choose a number that matches your system's stack behavior.
Again, as I mentioned, debug builds overflow much much quicker than release build, so you need to set this limit to a low number for debug builds.
I did not know that, thank you!
Probably need to put something in the documentation...