Skip to content

"Cannot run an executor inside another executor" - in tests #795

Closed
@humb1t

Description

@humb1t

1.6 version of async-std crashed our tests that works fine on prev version.

According to the stack trace asycn-std fails on stream.flush().await.map_err(|e| e.to_string())?; usage with a strange error message about executor inside another executor while we use #[async-std] attribute on tests and do not create executors here.

Maybe recent changes in sync module (for example we found a need to use Result instead of Optionin channel::Receiver) and our usage of it were the cause.

thread 'tests::single_threaded_async_stateful' panicked at 'cannot run an executor inside another executor', <::std::macros::panic macros>:2:4
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/6github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/6github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1063
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:204
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:224
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:470
  11: std::panicking::begin_panic
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/panicking.rs:397
  12: smol::work_stealing::Worker::enter
             at /home/humb1t/workspace/soramitsu/iroha/<::std::macros::panic macros>:2
  13: smol::run::run::{{closure}}
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/smol-0.1.10/src/run.rs:113
  14: smol::run::run
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/smol-0.1.10/src/run.rs:115
  15: async_std::task::builder::Builder::blocking::{{closure}}
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-std-1.6.0/src/task/builder.rs:154
  16: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current::{{closure}}
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-std-1.6.0/src/task/task_locals_wrapper.rs:60
  17: std::thread::local::LocalKey<T>::try_with
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/thread/local.rs:262
  18: std::thread::local::LocalKey<T>::with
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/thread/local.rs:239
  19: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-std-1.6.0/src/task/task_locals_wrapper.rs:55
  20: async_std::task::builder::Builder::blocking
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-std-1.6.0/src/task/builder.rs:154
  21: async_std::task::block_on::block_on
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-std-1.6.0/src/task/block_on.rs:33
  22: <iroha_network::mock::RequestStream as futures_io::if_std::AsyncWrite>::poll_flush
             at iroha_network/src/mock.rs:78
  23: <alloc::boxed::Box<T> as futures_io::if_std::AsyncWrite>::poll_flush
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/futures-io-0.3.5/src/lib.rs:413
  24: <async_std::io::write::flush::FlushFuture<T> as core::future::future::Future>::poll
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-std-1.6.0/src/io/write/flush.rs:17
  25: std::future::poll_with_tls_context
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/future.rs:102
  26: iroha_network::mock::Network::handle_message_async::{{closure}}
             at iroha_network/src/mock.rs:175
  27: <std::future::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/future.rs:44
  28: std::future::poll_with_tls_context
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/future.rs:102
  29: iroha_network::tests::single_threaded_async_stateful::{{closure}}::handle_connection::{{closure}}
             at iroha_network/src/lib.rs:292
  30: <std::future::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/future.rs:44
  31: std::future::poll_with_tls_context
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/future.rs:102
  32: iroha_network::mock::Network::listen::{{closure}}
             at iroha_network/src/mock.rs:144
  33: <std::future::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/future.rs:44
  34: std::future::poll_with_tls_context
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/future.rs:102
  35: iroha_network::tests::single_threaded_async_stateful::{{closure}}::{{closure}}
             at iroha_network/src/lib.rs:296
  36: <std::future::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/future.rs:44
  37: <async_std::task::builder::SupportTaskLocals<F> as core::future::future::Future>::poll::{{closure}}
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-std-1.6.0/src/task/builder.rs:174
  38: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current::{{closure}}
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-std-1.6.0/src/task/task_locals_wrapper.rs:60
  39: std::thread::local::LocalKey<T>::try_with
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/thread/local.rs:262
  40: std::thread::local::LocalKey<T>::with
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/thread/local.rs:239
  41: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-std-1.6.0/src/task/task_locals_wrapper.rs:55
  42: <async_std::task::builder::SupportTaskLocals<F> as core::future::future::Future>::poll
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-std-1.6.0/src/task/builder.rs:172
  43: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libcore/future/future.rs:118
  44: async_task::raw::RawTask<F,R,S,T>::run
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-task-3.0.0/src/raw.rs:502
  45: async_task::task::Task<T>::run
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-task-3.0.0/src/task.rs:265
  46: smol::work_stealing::Worker::execute::{{closure}}
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/smol-0.1.10/src/work_stealing.rs:176
  47: scoped_tls_hkt::ScopedKey<T>::set
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/scoped-tls-hkt-0.1.2/src/lib.rs:488
  48: smol::throttle::setup
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/smol-0.1.10/src/throttle.rs:31
  49: smol::work_stealing::Worker::execute
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/smol-0.1.10/src/work_stealing.rs:176
  50: smol::run::run::{{closure}}
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/smol-0.1.10/src/run.rs:151
  51: core::ops::function::FnOnce::call_once
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libcore/ops/function.rs:232
  52: smol::context::enter
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/smol-0.1.10/src/context.rs:8
  53: smol::run::run::{{closure}}::{{closure}}
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/smol-0.1.10/src/run.rs:112
  54: scoped_tls_hkt::ScopedKey<T>::set
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/scoped-tls-hkt-0.1.2/src/lib.rs:488
  55: smol::thread_local::ThreadLocalExecutor::enter
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/smol-0.1.10/src/thread_local.rs:57
  56: smol::run::run::{{closure}}
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/smol-0.1.10/src/run.rs:112
  57: smol::run::run::{{closure}}::{{closure}}
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/smol-0.1.10/src/run.rs:113
  58: smol::work_stealing::WORKER::<impl smol::work_stealing::WORKER>::set
             at /home/humb1t/workspace/soramitsu/iroha/<::scoped_tls_hkt::scoped_thread_local macros>:40
  59: smol::work_stealing::Worker::enter
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/smol-0.1.10/src/work_stealing.rs:149
  60: smol::run::run::{{closure}}
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/smol-0.1.10/src/run.rs:113
  61: smol::run::run
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/smol-0.1.10/src/run.rs:115
  62: async_std::task::builder::Builder::blocking::{{closure}}
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-std-1.6.0/src/task/builder.rs:154
  63: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current::{{closure}}
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-std-1.6.0/src/task/task_locals_wrapper.rs:60
  64: std::thread::local::LocalKey<T>::try_with
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/thread/local.rs:262
  65: std::thread::local::LocalKey<T>::with
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/thread/local.rs:239
  66: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-std-1.6.0/src/task/task_locals_wrapper.rs:55
  67: async_std::task::builder::Builder::blocking
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-std-1.6.0/src/task/builder.rs:154
  68: async_std::task::block_on::block_on
             at /home/humb1t/.cargo/registry/src/6github.com-1ecc6299db9ec823/async-std-1.6.0/src/task/block_on.rs:33
  69: iroha_network::tests::single_threaded_async_stateful
             at iroha_network/src/lib.rs:276
  70: iroha_network::tests::single_threaded_async_stateful::{{closure}}
             at iroha_network/src/lib.rs:276
  71: core::ops::function::FnOnce::call_once
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libcore/ops/function.rs:232
  72: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/liballoc/boxed.rs:1017
  73: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:86
  74: std::panicking::try
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/panicking.rs:281
  75: std::panic::catch_unwind
             at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/panic.rs:394
  76: test::run_test_in_process
             at src/libtest/lib.rs:542
  77: test::run_test::run_test_inner::{{closure}}
             at src/libtest/lib.rs:451
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
test tests::single_threaded_async_stateful ... FAILED

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions