Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode causes execution error. #1734

Open
Subway2023 opened this issue Feb 8, 2025 · 1 comment
Open

Decode causes execution error. #1734

Subway2023 opened this issue Feb 8, 2025 · 1 comment
Labels
solana The Solana target

Comments

@Subway2023
Copy link

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.
@seanyoung seanyoung added the solana The Solana target label Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solana The Solana target
Projects
None yet
Development

No branches or pull requests

3 participants
@seanyoung @Subway2023 and others