anza-xyz / move

Move compiler targeting llvm supported backends
https://discord.gg/wFgfjG9J
Apache License 2.0
108 stars 33 forks source link

[Bug] Expected to fail stdlib vector tests fail but abort codes mismatch #334

Open dmakarov opened 1 year ago

dmakarov commented 1 year ago

🐛 Bug

6 stdlib vector tests that are expected to fail on "index out of bounds" or "unpack parity mismatch" errors, indeed fail on Solana VM. On Solana checks for these errors are implemented as Rust run-time checks, and panic! at run-time with Solana VM reporting a panic. However, on Move VM these failures are built in the VM interpreter and reported with special abort codes, which are checked by the tests. The mismatch between what Solana VM and Move VM reprot makes these test fail.

To reproduce

Code snippet to reproduce

DUMP=1 \
LLVM_SYS_150_PREFIX=/path/move-dev \
PLATFORM_TOOLS_ROOT=/path/platform-tools \
MOVE_NATIVE=/path/move/language/move-native \
cargo run -p move-cli --features solana-backend --bin move -- test --solana -p language/move-stdlib -t 1 -s vector_tests

Stack trace/error message

event 0: "panicked at 'index out of bounds: the len is 1 but the index is 1', language/move-native/src/vector.rs:516:69"
event 1: "0x65, 0x65, 0x65, 0x65, 0x65"
[ FAIL    ] 0x1::vector_tests::borrow_out_of_range
event 0: "panicked at 'assertion failed: `(left == right)`\n  left: `1`,\n right: `0`', language/move-native/src/vector.rs:207:9"
event 1: "0x65, 0x65, 0x65, 0x65, 0x65"
[ FAIL    ] 0x1::vector_tests::destroy_non_empty
event 0: "panicked at 'popping from empty vec', language/move-native/src/vector.rs:695:51"
event 1: "0x65, 0x65, 0x65, 0x65, 0x65"
[ FAIL    ] 0x1::vector_tests::pop_out_of_range
event 0: "panicked at 'index out of bounds: the len is 0 but the index is 0', language/move-native/src/vector.rs:728:62"
event 1: "0x65, 0x65, 0x65, 0x65, 0x65"
[ FAIL    ] 0x1::vector_tests::swap_empty
event 0: "panicked at 'index out of bounds: the len is 4 but the index is 10', language/move-native/src/vector.rs:728:62"
event 1: "0x65, 0x65, 0x65, 0x65, 0x65"
[ FAIL    ] 0x1::vector_tests::swap_out_of_range
event 0: "panicked at 'index out of bounds: the len is 1 but the index is 1', language/move-native/src/vector.rs:728:62"
event 1: "0x65, 0x65, 0x65, 0x65, 0x65"
[ FAIL    ] 0x1::vector_tests::swap_remove_out_of_range

Expected Behavior

Test should pass.