aptos-core
aptos-core copied to clipboard
[Bug][move-compiler-v2] stack overflow in call_function_with_many_acquires.move
🐛 Bug
We seem to run out of stack compiling this function. V1 succeeds at compiling (although the resulting bytecode is invalid and yields a load failure).
To reproduce
% MOVE_COMPILER_V2=1 UB=1 mycargo test -p bytecode-verifier-transactional-tests -- call_function_with_many_acquires
yields
Finished test [unoptimized + debuginfo] target(s) in 0.50s
Running unittests src/lib.rs (target/debug/deps/bytecode_verifier_transactional_tests-99bb2fb4fd5f20a3)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running tests/tests.rs (target/debug/deps/tests-a56dba04cc5a38ce)
running 1 test
thread '<unknown>' has overflowed its stack
fatal runtime error: stack overflow
error: test failed, to rerun pass `-p bytecode-verifier-transactional-tests --test tests`
Caused by:
process didn't exit successfully: `/Users/brm/code/aptos-core/target/debug/deps/tests-a56dba04cc5a38ce call_function_with_many_acquires` (signal: 6, SIGABRT: process abort signal)
It happens during rewrite of expression: https://github.com/aptos-labs/aptos-core/blob/main/third_party/move/move-model/src/builder/exp_builder.rs#L1858 and setting RUST_MIN_STACK to 335544320 will make the compilation succeed.
Thanks. We can perhaps solve this by rewriting ExpData::rewrite_exp_and_pattern
to use an expression stack instead of recursion. But that will either involve terrible macros (as V1 had) or some major changes to ExpRewriterFunctions
.
Need to be sure
- it happens also in --release mode
If not its not urgent