tokio: Dropping an mpsc::Receiver deadlocks

Version

tokio-0.2.2

Platform

Linux 5.0.0-36-generic #39~18.04.1-Ubuntu SMP x86_64 GNU/Linux

Description

I have a #[tokio::test] test which is failing to exit cleanly. The test spawns a bunch of tasks, does some work, then runs to completion, but when tokio tries to shut down it blocks forever. According to gdb this is happening because mpsc::Receiver::drop is calling mpsc::chan::Rx::drop which calls mpsc::chan::Tx::drop which tries to acquire a mutex and then deadlocks. Here’s the full stack trace:

#0  __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
#1  0x00007ffff77b4023 in __GI___pthread_mutex_lock (mutex=0x7ffff0002690) at ../nptl/pthread_mutex_lock.c:78
#2  0x0000555555d687e5 in std::sys::unix::mutex::Mutex::lock (self=0x7ffff0002690) at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/sys/unix/mutex.rs:55
#3  0x0000555555d68671 in std::sys_common::mutex::Mutex::raw_lock (self=0x7ffff0002690) at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/sys_common/mutex.rs:36
#4  0x0000555555d79b05 in std::sync::mutex::Mutex<T>::lock (self=0x7ffff0002718) at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/sync/mutex.rs:220
#5  0x0000555555d7ba08 in <tokio::runtime::basic_scheduler::SchedulerPriv as tokio::task::Schedule>::schedule (self=0x7ffff00026f0, task=...)
    at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/runtime/basic_scheduler.rs:319
#6  0x00005555558bc075 in tokio::task::harness::Harness<T,S>::wake_by_ref (self=0x7ffff6df9db0) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/harness.rs:315
#7  0x00005555558bdddd in tokio::task::harness::Harness<T,S>::wake_by_val (self=...) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/harness.rs:299
#8  0x00005555557f3ed2 in tokio::task::waker::wake_by_val (ptr=0x7ffff0013290) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/waker.rs:84
#9  0x0000555555d86222 in core::task::wake::Waker::wake (self=...) at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/task/wake.rs:252
#10 0x0000555555dc9aba in tokio::sync::task::atomic_waker::AtomicWaker::wake (self=0x7ffff00141d8) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/sync/task/atomic_waker.rs:243
#11 0x000055555589b650 in <tokio::sync::mpsc::chan::Tx<T,S> as core::ops::drop::Drop>::drop (self=0x7ffff002e6f0)
    at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/sync/mpsc/chan.rs:236
#12 0x00005555557a4bb1 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#13 0x00005555557b0d91 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#14 0x000055555579f9e1 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#15 0x000055555579aae1 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#16 0x000055555579d34f in core::ptr::real_drop_in_place () at src/ln/peer/msg_channel.rs:227
#17 0x00005555557ad641 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#18 0x00005555557a7cb4 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#19 0x000055555578c911 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#20 0x0000555555791e40 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#21 0x0000555555799465 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#22 0x000055555579ec88 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#23 0x00005555557b2188 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#24 0x000055555589a33f in <tokio::sync::mpsc::chan::Rx<T,S> as core::ops::drop::Drop>::drop::{{closure}} (rx_fields_ptr=0x7ffff0019018)
    at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/sync/mpsc/chan.rs:323
#25 0x0000555555729384 in tokio::loom::std::causal_cell::CausalCell<T>::with_mut (self=0x7ffff0019018, f=...)
    at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/loom/std/causal_cell.rs:41
#26 0x000055555589896f in <tokio::sync::mpsc::chan::Rx<T,S> as core::ops::drop::Drop>::drop (self=0x7ffff0016a60)
    at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/sync/mpsc/chan.rs:320
#27 0x00005555557aa201 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#28 0x000055555579fbee in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#29 0x00005555557aebc5 in core::ptr::real_drop_in_place () at src/ln/peer/msg_channel_manager.rs:548
#30 0x00005555557a3171 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#31 0x00005555557b4257 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#32 0x00005555557a35e1 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#33 0x00005555557a3ff1 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#34 0x00005555557b42b4 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#35 0x000055555579c6f1 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#36 0x00005555557b498e in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#37 0x000055555579e342 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#38 0x00005555556b97ca in tokio::task::core::Core<T>::transition_to_consumed (self=0x7ffff0017420) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/core.rs:106
#39 0x00005555558f0e84 in tokio::task::harness::Harness<T,S>::do_cancel::{{closure}}::{{closure}} () at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/harness.rs:363
#40 0x000055555578b933 in core::ops::function::FnOnce::call_once () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ops/function.rs:223
#41 0x0000555555673cd3 in <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once (self=..., _args=()) at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panic.rs:316
#42 0x0000555555778ad9 in std::panicking::try::do_call (data=0x7ffff6dfedc8 "") at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panicking.rs:287
#43 0x0000555555e2e30a in __rust_maybe_catch_panic () at src/libpanic_unwind/lib.rs:81
#44 0x00005555557765fb in std::panicking::try (f=...) at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panicking.rs:265
#45 0x0000555555674933 in std::panic::catch_unwind (f=...) at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panic.rs:395
#46 0x00005555558f029c in tokio::task::harness::Harness<T,S>::do_cancel::{{closure}} () at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/harness.rs:361
#47 0x000055555571fd48 in tokio::loom::std::causal_cell::CausalCell<T>::with_mut (self=0x7ffff0017420, f=...)
    at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/loom/std/causal_cell.rs:41
#48 0x00005555558eda30 in tokio::task::harness::Harness<T,S>::do_cancel (self=..., res=...) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/harness.rs:359
#49 0x00005555558de852 in tokio::task::harness::Harness<T,S>::cancel (self=..., from_queue=true) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/harness.rs:342
#50 0x000055555594f5f2 in tokio::task::raw::cancel (ptr=0x7ffff00173f0, from_queue=true) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/raw.rs:196
#51 0x0000555555d491c7 in tokio::task::raw::RawTask::cancel_from_queue (self=...) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/raw.rs:145
#52 0x0000555555dba0a1 in tokio::task::Task<S>::shutdown (self=...) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/mod.rs:384
#53 0x0000555555d7ba9f in <tokio::runtime::basic_scheduler::SchedulerPriv as tokio::task::Schedule>::schedule (self=0x7ffff00026f0, task=...)
    at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/runtime/basic_scheduler.rs:324
#54 0x00005555558bbf85 in tokio::task::harness::Harness<T,S>::wake_by_ref (self=0x7ffff6dff130) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/harness.rs:315
#55 0x00005555558bdcfd in tokio::task::harness::Harness<T,S>::wake_by_val (self=...) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/harness.rs:299
#56 0x00005555557f3f92 in tokio::task::waker::wake_by_val (ptr=0x7ffff00173f0) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/waker.rs:84
#57 0x0000555555d86222 in core::task::wake::Waker::wake (self=...) at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/task/wake.rs:252
#58 0x0000555555dc9aba in tokio::sync::task::atomic_waker::AtomicWaker::wake (self=0x7ffff00168f8) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/sync/task/atomic_waker.rs:243
#59 0x000055555589aa20 in <tokio::sync::mpsc::chan::Tx<T,S> as core::ops::drop::Drop>::drop (self=0x7ffff0017510)
    at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/sync/mpsc/chan.rs:236
#60 0x0000555555793d31 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#61 0x000055555578c451 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#62 0x00005555557b47f1 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#63 0x00005555557b07c1 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#64 0x00005555557c7502 in core::ptr::drop_in_place (to_drop=0x7ffff0017510) at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:171
#65 alloc::sync::Arc<T>::drop_slow (self=0x7ffff00197e8) at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/liballoc/sync.rs:706
#66 0x00005555557ce086 in <alloc::sync::Arc<T> as core::ops::drop::Drop>::drop (self=0x7ffff00197e8) at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/liballoc/sync.rs:1234
#67 0x00005555557ab10e in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#68 0x00005555557a86f6 in core::ptr::real_drop_in_place () at src/ln/peer/manager.rs:110
#69 0x0000555555796ba1 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#70 0x00005555557b1c37 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#71 0x00005555557a1751 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#72 0x00005555557a2171 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#73 0x00005555557a4fe4 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#74 0x000055555578c8f1 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#75 0x000055555579a84e in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#76 0x00005555557aa402 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#77 0x00005555556b98ca in tokio::task::core::Core<T>::transition_to_consumed (self=0x7ffff00149e0) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/core.rs:106
#78 0x00005555558f0f04 in tokio::task::harness::Harness<T,S>::do_cancel::{{closure}}::{{closure}} () at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/harness.rs:363
#79 0x0000555555789393 in core::ops::function::FnOnce::call_once () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ops/function.rs:223
#80 0x0000555555673de3 in <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once (self=..., _args=()) at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panic.rs:316
#81 0x0000555555778f19 in std::panicking::try::do_call (data=0x7ffff6dff578 "\260\366\337\366\377\177") at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panicking.rs:287
#82 0x0000555555e2e30a in __rust_maybe_catch_panic () at src/libpanic_unwind/lib.rs:81
#83 0x000055555577628b in std::panicking::try (f=...) at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panicking.rs:265
#84 0x0000555555674543 in std::panic::catch_unwind (f=...) at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panic.rs:395
#85 0x00005555558f01ac in tokio::task::harness::Harness<T,S>::do_cancel::{{closure}} () at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/harness.rs:361
#86 0x0000555555729988 in tokio::loom::std::causal_cell::CausalCell<T>::with_mut (self=0x7ffff00149e0, f=...)
    at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/loom/std/causal_cell.rs:41
#87 0x00005555558ee8d0 in tokio::task::harness::Harness<T,S>::do_cancel (self=..., res=...) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/harness.rs:359
#88 0x00005555558df4b2 in tokio::task::harness::Harness<T,S>::cancel (self=..., from_queue=false) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/harness.rs:342
#89 0x000055555594f5b2 in tokio::task::raw::cancel (ptr=0x7ffff00149b0, from_queue=false) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/raw.rs:196
#90 0x0000555555dc022b in tokio::task::list::OwnedList<T>::shutdown (self=0x7ffff00026f0) at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/list.rs:68
#91 0x0000555555d7be53 in <tokio::runtime::basic_scheduler::BasicScheduler<P> as core::ops::drop::Drop>::drop (self=0x7ffff6dff970)
    at /home/shum/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/runtime/basic_scheduler.rs:359
#92 0x0000555555791935 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#93 0x000055555578c977 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#94 0x0000555555796fc1 in core::ptr::real_drop_in_place () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ptr/mod.rs:181
#95 0x00005555557f651a in geelightning::ln::peer::manager::test::connect_two_peer_managers () at src/ln/peer/manager.rs:176
#96 0x00005555559429fa in geelightning::ln::peer::manager::test::connect_two_peer_managers::{{closure}} () at src/ln/peer/manager.rs:176
#97 0x0000555555788fee in core::ops::function::FnOnce::call_once () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ops/function.rs:223
#98 0x00005555559c5e2f in <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/liballoc/boxed.rs:942
#99 0x0000555555e2e30a in __rust_maybe_catch_panic () at src/libpanic_unwind/lib.rs:81
#100 0x00005555559e180a in std::panicking::try () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panicking.rs:265
#101 std::panic::catch_unwind () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panic.rs:395
#102 test::run_test_in_process () at src/libtest/lib.rs:570
#103 test::run_test::run_test_inner::{{closure}} () at src/libtest/lib.rs:473
#104 0x00005555559ba696 in std::sys_common::backtrace::__rust_begin_short_backtrace () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/sys_common/backtrace.rs:136
#105 0x00005555559beae6 in std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}} () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/thread/mod.rs:469
#106 <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panic.rs:316
#107 std::panicking::try::do_call () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panicking.rs:287
#108 0x0000555555e2e30a in __rust_maybe_catch_panic () at src/libpanic_unwind/lib.rs:81
#109 0x00005555559bf476 in std::panicking::try () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panicking.rs:265
#110 std::panic::catch_unwind () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panic.rs:395
#111 std::thread::Builder::spawn_unchecked::{{closure}} () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/thread/mod.rs:468
#112 core::ops::function::FnOnce::call_once{{vtable-shim}} () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ops/function.rs:223
#113 0x0000555555e192ef in <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/liballoc/boxed.rs:942
#114 0x0000555555e2d7e0 in <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once () at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/liballoc/boxed.rs:942
#115 std::sys_common::thread::start_thread () at src/libstd/sys_common/thread.rs:13
#116 std::sys::unix::thread::Thread::new::thread_start () at src/libstd/sys/unix/thread.rs:79
#117 0x00007ffff77b16db in start_thread (arg=0x7ffff6e02700) at pthread_create.c:463
#118 0x00007ffff72c288f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

My code was working fine with tokio-0.2.0-alpha.5. I’ve only hit this problem with trying to upgrade to tokio-0.2.2. Interestingly, I had previously been using futures::channel::mpsc channels but swapped them out for tokio channels in attempt to fix this bug, only to find that tokio’s channels are deadlocking in the exact same way (Receiver::drop() -> Sender::drop() -> deadlock). I also had what seems like a similar problem in my own channel-like type that I had written where a lock was being shared between a sender and a receiver, and after upgrading to tokio-0.2.2 their destructors would call each other via wake and deadlock. I was able to fix that in my own code by releasing the lock before calling wake. Based on the stack trace it looks like something similar could be happening here.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (13 by maintainers)

Commits related to this issue

Most upvoted comments

I encountered the same bug in my codebase and I can confirm that updating Tokio to the version in master fixes it.