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

ethereum_abi::abi::Abi::decode_input_from_slice panic and crash program #58

Open
tdelabro opened this issue Jun 13, 2022 · 1 comment
Open

Comments

@tdelabro
Copy link

decode_input_from_slice sometimes crah

My code is the following

let (function, decoded_params) =
		match DEPOSIT_CONTRACT_ABI.decode_input_from_slice(&transaction.input.0) {
			Ok(d) => d,
			Err(_) => return Ok(()),
		};

Here is the backtrace:

thread 'main' panicked at 'range end index 4 out of range for slice of length 0', library/core/src/slice/index.rs:73:5
stack backtrace:
   0: rust_begin_unwind
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
   2: core::slice::index::slice_end_index_len_fail_rt
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/slice/index.rs:73:5
   3: core::ops::function::FnOnce::call_once
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/ops/function.rs:227:5
   4: core::intrinsics::const_eval_select
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/intrinsics.rs:2361:5
   5: core::slice::index::slice_end_index_len_fail
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/slice/index.rs:67:9
   6: ethereum_abi::abi::Abi::decode_input_from_slice
   7: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   8: <futures_util::future::try_maybe_done::TryMaybeDone<Fut> as core::future::future::Future>::poll
   9: <futures_util::future::try_join_all::TryJoinAll<F> as core::future::future::Future>::poll
  10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  11: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  12: <tokio::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
  13: eth_parser::main::{{closure}}
  14: std::thread::local::LocalKey<T>::with
  15: tokio::park::thread::CachedParkThread::block_on
  16: tokio::runtime::thread_pool::ThreadPool::block_on
  17: tokio::runtime::Runtime::block_on
  18: eth_parser::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Full trace:

thread 'main' panicked at 'range end index 4 out of range for slice of length 0', library/core/src/slice/index.rs:73:5
stack backtrace:
   0:     0x55e80b54d27d - std::backtrace_rs::backtrace::libunwind::trace::h22893a5306c091b4
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x55e80b54d27d - std::backtrace_rs::backtrace::trace_unsynchronized::h29c3bc6f9e91819d
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55e80b54d27d - std::sys_common::backtrace::_print_fmt::he497d8a0ec903793
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x55e80b54d27d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9c2a9d2774d81873
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x55e80b56f29c - core::fmt::write::hba4337c43d992f49
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/fmt/mod.rs:1194:17
   5:     0x55e80b547d11 - std::io::Write::write_fmt::heb73de6e02cfabed
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/io/mod.rs:1655:15
   6:     0x55e80b54eda5 - std::sys_common::backtrace::_print::h63c8b24acdd8e8ce
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x55e80b54eda5 - std::sys_common::backtrace::print::h426700d6240cdcc2
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x55e80b54eda5 - std::panicking::default_hook::{{closure}}::hc9a76eed0b18f82b
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:295:22
   9:     0x55e80b54ea59 - std::panicking::default_hook::h2e88d02087fae196
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:314:9
  10:     0x55e80b54f2f2 - std::panicking::rust_panic_with_hook::habfdcc2e90f9fd4c
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:698:17
  11:     0x55e80b54f1d7 - std::panicking::begin_panic_handler::{{closure}}::he054b2a83a51d2cd
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:588:13
  12:     0x55e80b54d734 - std::sys_common::backtrace::__rust_end_short_backtrace::ha48b94ab49b30915
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:138:18
  13:     0x55e80b54ef09 - rust_begin_unwind
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
  14:     0x55e80afb3fc3 - core::panicking::panic_fmt::h366d3a309ae17c94
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
  15:     0x55e80b571076 - core::slice::index::slice_end_index_len_fail_rt::hab01086a1430d984
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/slice/index.rs:73:5
  16:     0x55e80b568c77 - core::ops::function::FnOnce::call_once::h02950ad71da619df
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/ops/function.rs:227:5
  17:     0x55e80b56d146 - core::intrinsics::const_eval_select::h73e7b6f162eb47b3
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/intrinsics.rs:2361:5
  18:     0x55e80afb40d6 - core::slice::index::slice_end_index_len_fail::h2f0744292281ab75
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/slice/index.rs:67:9
  19:     0x55e80b07bfaf - ethereum_abi::abi::Abi::decode_input_from_slice::h69ff843441a587e0
  20:     0x55e80b061c9c - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hfc6e5399539d72eb
  21:     0x55e80b04be95 - <futures_util::future::try_maybe_done::TryMaybeDone<Fut> as core::future::future::Future>::poll::hc7850360150769d9
  22:     0x55e80b02db7e - <futures_util::future::try_join_all::TryJoinAll<F> as core::future::future::Future>::poll::h35f63be4ea6954d6
  23:     0x55e80b06099c - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h535b49f40b99dc62
  24:     0x55e80b05ca78 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h12b9dacf14f1e112
  25:     0x55e80b03aafa - <tokio::future::poll_fn::PollFn<F> as core::future::future::Future>::poll::h6805b7a2e8c3cde9
  26:     0x55e80b067a67 - eth_parser::main::{{closure}}::hed50cd11203d3a44
  27:     0x55e80b04ca3f - std::thread::local::LocalKey<T>::with::h5f1aba2ed9a3c839
  28:     0x55e80b04aefd - tokio::park::thread::CachedParkThread::block_on::h632428f18e9174a5
  29:     0x55e80b04b1fb - tokio::runtime::thread_pool::ThreadPool::block_on::hd9590cb649db3db9
  30:     0x55e80b0096fe - tokio::runtime::Runtime::block_on::hd8e5af3b368c359c
  31:     0x55e80b055c24 - eth_parser::main::h28fc9691d052d5cd
  32:     0x55e80b047c66 - std::sys_common::backtrace::__rust_begin_short_backtrace::h7b393c2764e1e58f
  33:     0x55e80b056bb8 - std::rt::lang_start::{{closure}}::h8105a3db185a32c1
  34:     0x55e80b542bee - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::had4f69b3aefb47a8
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/ops/function.rs:259:13
  35:     0x55e80b542bee - std::panicking::try::do_call::hf2ad5355fcafe775
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:492:40
  36:     0x55e80b542bee - std::panicking::try::h0a63ac363423e61e
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:456:19
  37:     0x55e80b542bee - std::panic::catch_unwind::h18088edcecb8693a
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panic.rs:137:14
  38:     0x55e80b542bee - std::rt::lang_start_internal::{{closure}}::ha7dad166dc711761
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:128:48
  39:     0x55e80b542bee - std::panicking::try::do_call::hda0c61bf3a57d6e6
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:492:40
  40:     0x55e80b542bee - std::panicking::try::hbc940e68560040a9
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:456:19
  41:     0x55e80b542bee - std::panic::catch_unwind::haed0df2aeb3fa368
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panic.rs:137:14
  42:     0x55e80b542bee - std::rt::lang_start_internal::h9c06694362b5b80c
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:128:20
  43:     0x55e80b055d12 - main
  44:     0x7f671f28ed90 - <unknown>
  45:     0x7f671f28ee40 - __libc_start_main
  46:     0x55e80afb4265 - _start
  47:                0x0 - <unknown>
@FelipeRosa
Copy link
Owner

Hi @tdelabro,

I wasn't able to work on the library in the past few months. I apologize for that.

It seems the slice you are passing as argument for the function has length < 4 and this case is not being handled by the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants