tokio-rs / tokio

A runtime for writing reliable asynchronous applications with Rust. Provides I/O, networking, scheduling, timers, ...
https://tokio.rs
MIT License
25.71k stars 2.35k forks source link

app stuck dropping tokio::runtime::runtime::Runtime #6609

Closed DaKnig closed 1 month ago

DaKnig commented 1 month ago

Version

~/prog/dewduct $ cargo tree | grep tokio ├── tokio v1.37.0 │ └── tokio-macros v2.2.0 (proc-macro)

Platform

Linux angrymob 6.9.0 #1-postmarketos-allwinner SMP PREEMPT aarch64 Linux

Description

I am using tokio::task::spawn_blocking in a few places and have a #[tokio::main].

When the program finishes, it is stuck dropping the Runtime.

Debugger shows this backtrace:

#0  0x0000ffff8ec02a40 in __syscall6
    (f=<optimized out>, e=<optimized out>, d=<optimized out>, c=<optimized out>, b=<optimized out>, a=<optimized out>, n=98) at ./arch/aarch64/syscall_arch.h:71
#1  syscall (n=98) at src/misc/syscall.c:20
#2  0x0000aaaadfb4d330 in std::sys::sync::condvar::futex::Condvar::wait ()
#3  0x0000aaaadf7985e0 in std::sync::condvar::Condvar::wait<()>
    (self=0xffff8bfdae40, guard=...)
    at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sync/condvar.rs:189
#4  0x0000aaaadf7c7854 in tokio::runtime::park::Inner::park (self=0xffff8bfdae30)
    at src/runtime/park.rs:116
#5  0x0000aaaadf7c8208 in tokio::runtime::park::{impl#4}::park::{closure#0}
    (park_thread=0xffff8ec7b170) at src/runtime/park.rs:254
#6  0x0000aaaadf7c83e0 in tokio::runtime::park::{impl#4}::with_current::{closure#0}<tokio::runtime::park::{impl#4}::park::{closure_env#0}, ()> (inner=0xffff8ec7b170)
    at src/runtime/park.rs:268
#7  0x0000aaaadf7d2d94 in std::thread::local::LocalKey<tokio::runtime::park::ParkThread>::try_with<tokio::runtime::park::ParkThread, tokio::runtime::park::{impl#4}::with_current::{closure_env#0}<tokio::runtime::park::{impl#4}::park::{closure_env#0}, ()>, ()> (self=0xaaaadfd7d108, f=...)
    at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/thread/local.rs:284
#8  0x0000aaaadf7c8324 in tokio::runtime::park::CachedParkThread::with_current<tokio::runtime::park::{impl#4}::park::{closure_env#0}, ()> (self=0xffffff5d6c5e, f=...)
    at src/runtime/park.rs:268
#9  0x0000aaaadf7c8180 in tokio::runtime::park::CachedParkThread::park
    (self=0xffffff5d6c5e) at src/runtime/park.rs:254
#10 0x0000aaaadf7c8760 in tokio::runtime::park::CachedParkThread::block_on<&mut tokio::sync::oneshot::Receiver<()>> (self=0xffffff5d6c5e, f=0xffffff5d70d0)
    at src/runtime/park.rs:285

every time I look at it its stuck in roughly the same: awaiting something like a futex...

Darksonn commented 1 month ago

Tokio is waiting for your spawn_blocking tasks to exit.