Skip to content

WASM unreachable instruction executed #156

@0xOmarA

Description

@0xOmarA

Versions

  • Polkadot SDK commit 1a512570552119a49a8ecb2abfb7021954c4422d
  • Differential Testing tool commit 8b1afc36a32bb27e4d9680f08afe97e1946b0269
  • Resolc Compiler Tests commit 4372389f90af54b5c2543050f228a6ca2f44e787

Description

Some of the tests in the differential testing suite fail due to an "Unreachable reached" failure. The following is the error that we get:

Y M0 - /Users/omarabdulla/parity/revive-dt/resolc-compiler-tests/fixtures/solidity/complex/solidity_by_example/hacks/hiding_malicious_code_with_external_contract/test.json
	Case Index   0: Case Failed - Reason: Failed to handle function call step: Failed during callframe tracing phase of input handling: Failed to obtain debug trace from kitchensink proxy: server returned an error response: error code 4003: Client error: Execution failed: Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed
WASM backtrace:
error while executing at wasm backtrace:
    0: 0x2339f8 - revive_dev_runtime.wasm!__rustc[4794b31dd7191200]::rust_begin_unwind
    1:  0x10bae - revive_dev_runtime.wasm!core::panicking::panic_fmt::h6d5c9cb2562e2e31
    2:  0x10d0b - revive_dev_runtime.wasm!core::panicking::panic_bounds_check::h41b143710ce5aa7d
    3: 0x127d3c - revive_dev_runtime.wasm!<pallet_revive::evm::tracing::call_tracing::CallTracer<Gas,GasMapper> as pallet_revive::tracing::Tracing>::log_event::ha9680cf01b706c08
    4: 0x172672 - revive_dev_runtime.wasm!environmental::local_key::LocalKey<T>::with::h3462e1e2f892cd88
    5: 0x199c43 - revive_dev_runtime.wasm!<pallet_revive::exec::Stack<T,E> as pallet_revive::exec::PrecompileExt>::deposit_event::h15e593cd7affb344
    6: 0x14d361 - revive_dev_runtime.wasm!pallet_revive::vm::pvm::env::<impl pallet_revive::vm::pvm::Runtime<E,M>>::handle_ecall::{{closure}}::{{closure}}::hb0b909d68e2909e4
    7: 0x141af5 - revive_dev_runtime.wasm!pallet_revive::vm::pvm::env::<impl pallet_revive::vm::pvm::Runtime<E,M>>::handle_interrupt::h784aad1ba5df072a
    8: 0x140cc4 - revive_dev_runtime.wasm!pallet_revive::vm::pvm::PreparedCall<E>::call::hc9cf974c7f5c290b
    9: 0x1a9cc4 - revive_dev_runtime.wasm!<pallet_revive::vm::ContractBlob<T> as pallet_revive::exec::Executable<T>>::execute::h94b1135773e165c6
   10: 0x1bd8d2 - revive_dev_runtime.wasm!frame_support::storage::transactional::with_transaction::h1691df36bd750eff
   11: 0x1897c7 - revive_dev_runtime.wasm!pallet_revive::exec::Stack<T,E>::run::h6d3cd58ea7acd0be
   12: 0x19a481 - revive_dev_runtime.wasm!<pallet_revive::exec::Stack<T,E> as pallet_revive::exec::PrecompileExt>::call::h8d3041f7c933f783
   13: 0x1408dc - revive_dev_runtime.wasm!pallet_revive::vm::pvm::Runtime<E,M>::call::h5f053ac21cd01ee3
   14: 0x1448d1 - revive_dev_runtime.wasm!pallet_revive::vm::pvm::env::<impl pallet_revive::vm::pvm::Runtime<E,M>>::handle_ecall::{{closure}}::{{closure}}::h189a32e24df4f396
   15: 0x14190c - revive_dev_runtime.wasm!pallet_revive::vm::pvm::env::<impl pallet_revive::vm::pvm::Runtime<E,M>>::handle_interrupt::h784aad1ba5df072a
   16: 0x140cc4 - revive_dev_runtime.wasm!pallet_revive::vm::pvm::PreparedCall<E>::call::hc9cf974c7f5c290b
   17: 0x1a9cc4 - revive_dev_runtime.wasm!<pallet_revive::vm::ContractBlob<T> as pallet_revive::exec::Executable<T>>::execute::h94b1135773e165c6
   18: 0x1bd8d2 - revive_dev_runtime.wasm!frame_support::storage::transactional::with_transaction::h1691df36bd750eff
   19: 0x1897c7 - revive_dev_runtime.wasm!pallet_revive::exec::Stack<T,E>::run::h6d3cd58ea7acd0be
   20: 0x192075 - revive_dev_runtime.wasm!pallet_revive::exec::Stack<T,E>::run_call::hee50afbc61b484f9
   21: 0x1712c2 - revive_dev_runtime.wasm!pallet_revive::<impl pallet_revive::pallet::Pallet<T>>::run_guarded::{{closure}}::h6996538f723ccf2d
   22: 0x170b91 - revive_dev_runtime.wasm!environmental::local_key::LocalKey<T>::with::h166c2a48d43bed84
   23: 0x12f74b - revive_dev_runtime.wasm!pallet_revive::<impl pallet_revive::pallet::Pallet<T>>::bare_call::hc34a5e1274b6ac21
   24: 0x1bf1f1 - revive_dev_runtime.wasm!frame_support::storage::transactional::with_transaction::h313efc428ff5aa58
   25: 0x16c0db - revive_dev_runtime.wasm!<pallet_revive::pallet::Call<T> as frame_support::traits::dispatch::UnfilteredDispatchable>::dispatch_bypass_filter::{{closure}}::h8cba7bbecaa6f09b
   26: 0x174b39 - revive_dev_runtime.wasm!environmental::local_key::LocalKey<T>::with::h9f4a332b7aa8e54f
   27: 0x20a118 - revive_dev_runtime.wasm!<revive_dev_runtime::RuntimeCall as frame_support::traits::dispatch::UnfilteredDispatchable>::dispatch_bypass_filter::h8b163ec44c0a35ef
   28: 0x1bb6d2 - revive_dev_runtime.wasm!<T as sp_runtime::traits::transaction_extension::dispatch_transaction::DispatchTransaction<Call>>::dispatch_transaction::hf69048316f84749d
   29: 0x1c6585 - revive_dev_runtime.wasm!<sp_runtime::generic::checked_extrinsic::CheckedExtrinsic<AccountId,Call,Extension> as sp_runtime::traits::Applyable>::apply::h9fc9b3089368ac80
   30: 0x15d8c1 - revive_dev_runtime.wasm!frame_executive::Executive<System,Block,Context,UnsignedValidator,AllPalletsWithSystem,COnRuntimeUpgrade>::do_apply_extrinsic::h4689f2e8a02c8c37
   31: 0x171816 - revive_dev_runtime.wasm!environmental::local_key::LocalKey<T>::with::h1a1be8b257dda566
   32: 0x20fe41 - revive_dev_runtime.wasm!<revive_dev_runtime::Runtime as pallet_revive::runtime_decl_for_revive_api::ReviveApiV1<sp_runtime::generic::block::Block<sp_runtime::generic::header::Header<u32,sp_runtime::traits::BlakeTwo256>,pallet_revive::evm::runtime::UncheckedExtrinsic<sp_runtime::multiaddress::MultiAddress<sp_core::crypto::AccountId32,()>,sp_runtime::MultiSignature,revive_dev_runtime::EthExtraImpl>>,sp_core::crypto::AccountId32,u128,u32,u32>>::trace_tx::h07ba72e380958a76
   33: 0x2154b8 - revive_dev_runtime.wasm!ReviveApi_trace_tx

It appears that this is an error in the tracing as it only happens when tracing. It doesn't happen for all tests, just two.

Steps to Reproduce

The following command can be used to reproduce this through the differential testing tool. Note that the following command will clone and rebuild the polkadot-sdk at the commit specified in the versions above.

(
    mkdir test;
    cd test;

    git clone https://github.com/paritytech/revive-differential-tests --rev 8b1afc36a32bb27e4d9680f08afe97e1946b0269;
    git clone https://github.com/paritytech/resolc-compiler-tests --rev 4372389f90af54b5c2543050f228a6ca2f44e787;
    git clone https://github.com/paritytech/polkadot-sdk/ --rev 1a512570552119a49a8ecb2abfb7021954c4422d;

    cargo build --release --manifest-path ./revive-differential-tests/Cargo.toml;
    cargo build --release --manifest-path ./polkadot-sdk/Cargo.toml --package pallet-revive-eth-rpc --package revive-dev-node;
    
    find "./revive-differential-tests/target/release/" -type d -mindepth 1 -prune -o -type f \( -perm -100 -o -perm -010 -o -perm -001 \) -exec cp -p {} "."/ \;
    find "./polkadot-sdk/target/release/" -type d -mindepth 1 -prune -o -type f \( -perm -100 -o -perm -010 -o -perm -001 \) -exec cp -p {} "."/ \;
    
    cp ./revive-differential-tests/genesis.json .;
    mkdir workdir;
    cat > corp.json <<EOF
{
    "name": "MatterLabs Solidity Simple, Complex, and Semantic Tests",
    "path": "./resolc-compiler-tests/fixtures/solidity/complex/solidity_by_example/hacks/hiding_malicious_code_with_external_contract/test.json"
}
EOF
    
    RUST_LOG="info" ./retester \
        --corpus "corp.json" \
        --workdir "workdir" \
        --number-of-nodes 5 \
        --kitchensink "./substrate-node" \
        --revive-dev-node "./revive-dev-node" \
        --eth_proxy "./eth-rpc" \
        > logs.log \
        2> output.log
)

After this finishes running look at the ./test/logs.log for the logs and ./test/output.log for the tool's output and status of each test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions