Skip to content

Instantly share code, notes, and snippets.

@marekyggdrasil
Created January 1, 2021 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marekyggdrasil/c953f486cdeb9a7fba8de8542b783e9d to your computer and use it in GitHub Desktop.
Save marekyggdrasil/c953f486cdeb9a7fba8de8542b783e9d to your computer and use it in GitHub Desktop.

Report

A tester managed to trigger tokio-runtime-worker panic via v3 Owner-API call scan method. His findings are available here and this report is meant to reproduce his results.

Environment

My wallet

$ ~/bin/grin-wallet-v5.0.0-rc.1 -V
grin-wallet 5.0.0-rc.1

my system

$ uname -s -r -v -m -p -i -o
Linux 4.19.0-12-amd64 #1 SMP Debian 4.19.152-1 (2020-10-18) x86_64 unknown unknown GNU/Linux

Steps

Run the wallet in the listener mode

$ ~/bin/grin-wallet-v5.0.0-rc.1 -r "https://grinnode.live:3413" owner_api
20210101 06:59:12.744 ERROR grin_wallet_impls::node_clients::http - Error calling get_version: ResponseError error: Cannot parse response
20210101 06:59:12.744 ERROR grin_wallet_impls::node_clients::http - Unable to contact Node to get version info: Client Callback Error: Error calling get_version: ResponseError error: Cannot parse response
Password: 
20210101 06:59:14.657 WARN grin_wallet_controller::controller - Starting HTTP Owner API server at 127.0.0.1:3420.
20210101 06:59:14.657 WARN grin_wallet_controller::controller - HTTP Owner listener started.

run the scan method

$ python wallet_v3.py 
Traceback (most recent call last):
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 706, in urlopen
    chunked=chunked,
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/http/client.py", line 1321, in getresponse
    response.begin()
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/http/client.py", line 296, in begin
    version, status, reason = self._read_status()
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/http/client.py", line 265, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 756, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/site-packages/urllib3/util/retry.py", line 531, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/site-packages/urllib3/packages/six.py", line 734, in reraise
    raise value.with_traceback(tb)
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 706, in urlopen
    chunked=chunked,
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/http/client.py", line 1321, in getresponse
    response.begin()
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/http/client.py", line 296, in begin
    version, status, reason = self._read_status()
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/http/client.py", line 265, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "wallet_v3.py", line 462, in <module>
    pp.pprint(wallet.scan())
  File "wallet_v3.py", line 184, in scan
    resp = self.post_encrypted('scan', params)
  File "wallet_v3.py", line 86, in post_encrypted
    'body_enc': encrypted
  File "wallet_v3.py", line 62, in post
    auth=(self.api_user, self.api_password))
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/site-packages/requests/api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/home/marek/.pyenv/versions/3.7.3/lib/python3.7/site-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

wallet output log reports tokio-runtime-worker error

20210101 07:00:55.613 ERROR grin_util::logger - 
thread 'tokio-runtime-worker' panicked at 'Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.': /home/vsts/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/enter.rs:38   0: grin_util::logger::send_panic_to_log::{{closure}}
   1: std::panicking::rust_panic_with_hook
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:581
   2: std::panicking::begin_panic::{{closure}}
   3: std::sys_common::backtrace::__rust_end_short_backtrace
   4: std::panicking::begin_panic
   5: tokio::runtime::enter::enter
   6: tokio::runtime::thread_pool::ThreadPool::block_on
   7: tokio::runtime::context::enter
   8: <grin_wallet_impls::node_clients::http::HTTPNodeClient as grin_wallet_libwallet::types::NodeClient>::get_outputs_from_node
   9: grin_wallet_libwallet::internal::updater::refresh_output_state
  10: grin_wallet_libwallet::internal::updater::refresh_outputs
  11: grin_wallet_libwallet::api_impl::owner::update_outputs
  12: grin_wallet_libwallet::api_impl::owner::scan
  13: grin_wallet_api::owner::Owner<L,C,K>::scan
  14: <grin_wallet_api::owner::Owner<L,C,K> as grin_wallet_api::owner_rpc::OwnerRpc>::scan
  15: <dyn grin_wallet_api::owner_rpc::OwnerRpc as easy_jsonrpc_mw::Handler>::handle
  16: easy_jsonrpc_mw::handle_call
  17: easy_jsonrpc_mw::handle_parsed_request
  18: easy_jsonrpc_mw::Handler::handle_request
  19: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  20: <hyper::proto::h1::dispatch::Server<S,hyper::body::body::Body> as hyper::proto::h1::dispatch::Dispatch>::poll_msg
  21: hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_catch
  22: <hyper::server::conn::upgrades::UpgradeableConnection<I,S,E> as core::future::future::Future>::poll
  23: <hyper::server::conn::spawn_all::NewSvcTask<I,N,S,E,W> as core::future::future::Future>::poll
  24: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  25: tokio::runtime::task::raw::poll
  26: std::thread::local::LocalKey<T>::with
  27: tokio::runtime::thread_pool::worker::Context::run_task
  28: tokio::runtime::thread_pool::worker::Context::run
  29: tokio::macros::scoped_tls::ScopedKey<T>::set
  30: tokio::runtime::thread_pool::worker::run
  31: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
  32: tokio::runtime::task::core::Core<T,S>::poll
  33: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  34: tokio::runtime::task::harness::Harness<T,S>::poll
  35: tokio::runtime::blocking::pool::Inner::run
  36: tokio::runtime::context::enter
  37: std::sys_common::backtrace::__rust_begin_short_backtrace
  38: core::ops::function::FnOnce::call_once{{vtable.shim}}
  39: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/alloc/src/boxed.rs:1042
      <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/alloc/src/boxed.rs:1042
      std::sys::unix::thread::Thread::new::thread_start
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys/unix/thread.rs:87
  40: start_thread
  41: clone



Thread 'tokio-runtime-worker' panicked with message:
"Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks."
See /home/marek/wallets/alice/grin-wallet.log for further details.
20210101 07:01:37.393 ERROR grin_util::logger - 
thread 'unnamed' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"': impls/src/client_utils/client.rs:349   0: grin_util::logger::send_panic_to_log::{{closure}}
   1: std::panicking::rust_panic_with_hook
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:581
   2: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:484
   3: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:153
   4: rust_begin_unwind
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:483
   5: core::panicking::panic_fmt
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:85
   6: core::option::expect_none_failed
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/option.rs:1234
   7: std::sys_common::backtrace::__rust_begin_short_backtrace
   8: core::ops::function::FnOnce::call_once{{vtable.shim}}
   9: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/alloc/src/boxed.rs:1042
      <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/alloc/src/boxed.rs:1042
      std::sys::unix::thread::Thread::new::thread_start
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys/unix/thread.rs:87
  10: start_thread
  11: clone



Thread 'unnamed' panicked with message:
"called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }""
See /home/marek/wallets/alice/grin-wallet.log for further details.
20210101 07:01:37.394 ERROR grin_util::logger - 
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Any': impls/src/client_utils/client.rs:351   0: grin_util::logger::send_panic_to_log::{{closure}}
   1: std::panicking::rust_panic_with_hook
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:581
   2: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:484
   3: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:153
   4: rust_begin_unwind
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:483
   5: core::panicking::panic_fmt
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:85
   6: core::option::expect_none_failed
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/option.rs:1234
   7: grin_wallet_impls::client_utils::client::Client::send_request
   8: grin_wallet_impls::client_utils::client::Client::post
   9: <grin_wallet_impls::node_clients::http::HTTPNodeClient as grin_wallet_libwallet::types::NodeClient>::get_chain_tip
  10: grin_wallet_libwallet::internal::updater::refresh_outputs
  11: grin_wallet_libwallet::api_impl::owner::update_outputs
  12: grin_wallet_libwallet::api_impl::owner::scan
  13: grin_wallet_api::owner::Owner<L,C,K>::scan
  14: <grin_wallet_api::owner::Owner<L,C,K> as grin_wallet_api::owner_rpc::OwnerRpc>::scan
  15: <dyn grin_wallet_api::owner_rpc::OwnerRpc as easy_jsonrpc_mw::Handler>::handle
  16: easy_jsonrpc_mw::handle_call
  17: easy_jsonrpc_mw::handle_parsed_request
  18: easy_jsonrpc_mw::Handler::handle_request
  19: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  20: <hyper::proto::h1::dispatch::Server<S,hyper::body::body::Body> as hyper::proto::h1::dispatch::Dispatch>::poll_msg
  21: hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_catch
  22: <hyper::server::conn::upgrades::UpgradeableConnection<I,S,E> as core::future::future::Future>::poll
  23: <hyper::server::conn::spawn_all::NewSvcTask<I,N,S,E,W> as core::future::future::Future>::poll
  24: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  25: tokio::runtime::task::raw::poll
  26: std::thread::local::LocalKey<T>::with
  27: tokio::runtime::thread_pool::worker::Context::run_task
  28: tokio::runtime::thread_pool::worker::Context::run
  29: tokio::macros::scoped_tls::ScopedKey<T>::set
  30: tokio::runtime::thread_pool::worker::run
  31: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
  32: tokio::runtime::task::core::Core<T,S>::poll
  33: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  34: tokio::runtime::task::harness::Harness<T,S>::poll
  35: tokio::runtime::blocking::pool::Inner::run
  36: tokio::runtime::context::enter
  37: std::sys_common::backtrace::__rust_begin_short_backtrace
  38: core::ops::function::FnOnce::call_once{{vtable.shim}}
  39: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/alloc/src/boxed.rs:1042
      <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/alloc/src/boxed.rs:1042
      std::sys::unix::thread::Thread::new::thread_start
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys/unix/thread.rs:87
  40: start_thread
  41: clone



Thread 'tokio-runtime-worker' panicked with message:
"called `Result::unwrap()` on an `Err` value: Any"
See /home/marek/wallets/alice/grin-wallet.log for further details.

Conclusion

Error reproduced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment