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

JoinHandle::abort() panics with "scheduler context missing" #3157

Closed
manuthambi opened this issue Nov 20, 2020 · 0 comments
Closed

JoinHandle::abort() panics with "scheduler context missing" #3157

manuthambi opened this issue Nov 20, 2020 · 0 comments
Assignees
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug. M-runtime Module: tokio/runtime

Comments

@manuthambi
Copy link

Version

tokio v0.3.4
tokio-macros v0.3.1

Platform
Linux main-server 4.19.0-12-amd64 #1 SMP Debian 4.19.152-1 (2020-10-18) x86_64 GNU/Linux

Description
JoinHandle::abort() on a task which is blocked results in the abort call panicing with scheduler context missing

Here is the code snippet:

#[tokio::main]
async fn main() {
    let handle = tokio::spawn(async move {
        println!("task started");
        tokio::time::sleep(std::time::Duration::new(100, 0)).await
    });

    // wait for task to sleep.
    tokio::time::sleep(std::time::Duration::new(1, 0)).await;

    handle.abort();
    let _ = handle.await;
}

Here is the resulting panic:

  Compiling rust v0.1.0 (/misc/home/manu/programs/rust)
    Finished dev [unoptimized + debuginfo] target(s) in 0.96s
     Running `/tmp/rust-target/debug/rust`
task started
thread 'main' panicked at 'scheduler context missing', /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/runtime/thread_pool/worker.rs:633:31
stack backtrace:
   0: rust_begin_unwind
             at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/panicking.rs:475
   1: core::panicking::panic_fmt
             at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/core/src/panicking.rs:85
   2: core::option::expect_failed
             at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/core/src/option.rs:1213
   3: core::option::Option<T>::expect
             at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/core/src/option.rs:333
   4: tokio::runtime::thread_pool::worker::<impl tokio::runtime::task::Schedule for alloc::sync::Arc<tokio::runtime::thread_pool::worker::Worker>>::release::{{closure}}
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/runtime/thread_pool/worker.rs:633
   5: tokio::macros::scoped_tls::ScopedKey<T>::with
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/macros/scoped_tls.rs:72
   6: tokio::runtime::thread_pool::worker::<impl tokio::runtime::task::Schedule for alloc::sync::Arc<tokio::runtime::thread_pool::worker::Worker>>::release
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/runtime/thread_pool/worker.rs:632
   7: tokio::runtime::task::core::Core<T,S>::release::{{closure}}
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/runtime/task/core.rs:264
   8: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/loom/std/unsafe_cell.rs:10
   9: tokio::runtime::task::core::Core<T,S>::release
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/runtime/task/core.rs:260
  10: tokio::runtime::task::harness::Harness<T,S>::complete
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/runtime/task/harness.rs:322
  11: tokio::runtime::task::harness::Harness<T,S>::cancel_task
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/runtime/task/harness.rs:302
  12: tokio::runtime::task::harness::Harness<T,S>::shutdown
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/runtime/task/harness.rs:285
  13: tokio::runtime::task::raw::shutdown
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/runtime/task/raw.rs:130
  14: tokio::runtime::task::raw::RawTask::shutdown
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/runtime/task/raw.rs:90
  15: tokio::runtime::task::join::JoinHandle<T>::abort
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/runtime/task/join.rs:195
  16: rust::main::{{closure}}
             at ./src/main.rs:11
  17: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/core/src/future/mod.rs:79
  18: tokio::park::thread::CachedParkThread::block_on::{{closure}}
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/park/thread.rs:263
  19: tokio::coop::with_budget::{{closure}}
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/coop.rs:121
  20: std::thread::local::LocalKey<T>::try_with
             at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/thread/local.rs:265
  21: std::thread::local::LocalKey<T>::with
             at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/thread/local.rs:241
  22: tokio::coop::with_budget
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/coop.rs:114
  23: tokio::coop::budget
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/coop.rs:98
  24: tokio::park::thread::CachedParkThread::block_on
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/park/thread.rs:263
  25: tokio::runtime::enter::Enter::block_on
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/runtime/enter.rs:151
  26: tokio::runtime::thread_pool::ThreadPool::block_on
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/runtime/thread_pool/mod.rs:71
  27: tokio::runtime::Runtime::block_on
             at /misc/home/manu/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.3.4/src/runtime/mod.rs:452
  28: rust::main
             at ./src/main.rs:1
  29: core::ops::function::FnOnce::call_once
             at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/core/src/ops/function.rs:227
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug. M-runtime Module: tokio/runtime
Projects
None yet
Development

No branches or pull requests

3 participants