solang icon indicating copy to clipboard operation
solang copied to clipboard

Decode causes execution error.

Open Subway2023 opened this issue 11 months ago • 1 comments

Version: v0.3.3: Atlantis Description: abi.decode will cause the program to throw an execution error. If I comment out abi.decode, the program runs normally.

contract test {
    uint[2][] public originalData;
    uint[2][] public decodedData;
    function encodeData() public returns (uint) {
        originalData.push([1, 2]);
        originalData.push([3, 4]);
        originalData.push([5, 6]);
        bytes memory encodedData=abi.encode(originalData);
        decodedData = abi.decode(encodedData, (uint[2][]));
        // return decodedData[1][1];
    }
}

Reproduction: I set up a Solang compilation and execution environment to test the program.

solang/target/debug/vmRunNoPara test.sol test encodeData

The execution error is as follows:

Contract name: test
function new for A9HtWExjHDpVEXrSUT3jN8V8zrH3zE1cF3uw54VuuV7Z
input: 872ccdc6190148bc
running bpf with calldata:872ccdc6190148bc
program: A9HtWExjHDpVEXrSUT3jN8V8zrH3zE1cF3uw54VuuV7Z
static: length:8 0000000000000000
offset:28 prev:10 next:10 length:0 allocated:0 
function encodeData for A9HtWExjHDpVEXrSUT3jN8V8zrH3zE1cF3uw54VuuV7Z
input: fc5125a8e51a188a
running bpf with calldata:fc5125a8e51a188a
program: A9HtWExjHDpVEXrSUT3jN8V8zrH3zE1cF3uw54VuuV7Z
static: length:8 2800000000000000
offset:28 prev:10 next:f8 length:192 allocated:1 010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000
offset:f8 prev:28 next:10 length:0 allocated:0 
thread 'main' panicked at src/tests/solana.rs:1857:38:
error AccessViolation(219, Load, 24, 4, "unknown")
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7608018cbdac9e55d0d13529cf43adc33d53efcf/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_fmt
             at /rustc/7608018cbdac9e55d0d13529cf43adc33d53efcf/library/core/src/panicking.rs:74:14
   2: solang::tests::solana::VmFunction::call_with_error_code
             at ./src/tests/solana.rs:1857:38
   3: solang::tests::solana::VmFunction::call
             at ./src/tests/solana.rs:1815:15
   4: vmRunNoPara::function_call_with_account
             at ./src/bin/vmRunNoPara.rs:205:11
   5: vmRunNoPara::main::{{closure}}
             at ./src/bin/vmRunNoPara.rs:259:9
   6: std::panicking::try::do_call
             at /root/.rustup/toolchains/nightly-2024-09-30-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:557:40
   7: __rust_try
   8: std::panicking::try
             at /root/.rustup/toolchains/nightly-2024-09-30-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:520:19
   9: std::panic::catch_unwind
             at /root/.rustup/toolchains/nightly-2024-09-30-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:358:14
  10: vmRunNoPara::main
             at ./src/bin/vmRunNoPara.rs:258:19
  11: core::ops::function::FnOnce::call_once
             at /root/.rustup/toolchains/nightly-2024-09-30-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Subway2023 avatar Feb 08 '25 15:02 Subway2023