Comments (5)
FWIW, blocking behavior was detected by a user on wasm32 builds (using std::sync::mpsc::Recevier::try_recv()
) where the main thread is not allowed to block.
I tracked it down to Mutex
contention in https://users.rust-lang.org/t/wasm-winit-wgpu-weird-error-about-waiting-on-the-main-thread-despite-not-waiting-on-the-main-thread/96804/5
from crossbeam.
Also note that a similar block on the sender happens in the bounded channel.
Stack trace of sender:
#0 0x000055555557d6a8 in core::sync::atomic::atomic_compare_exchange_weak<usize> (dst=0x5555555e2c80, old=110471369, new=110471370, success=core::sync::atomic::Ordering::SeqCst, failure=core::sync::atomic::Ordering::Relaxed)
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/sync/atomic.rs:3278
#1 0x0000555555572252 in core::sync::atomic::AtomicUsize::compare_exchange_weak (self=0x5555555e2c80, current=110471369, new=110471370, success=core::sync::atomic::Ordering::SeqCst, failure=core::sync::atomic::Ordering::Relaxed)
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/sync/atomic.rs:2485
#2 0x00005555555702d9 in crossbeam_channel::flavors::array::Channel<usize>::start_send<usize> (self=0x5555555e2c00, token=0x7fffee3f5930) at /home/ben/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-channel-0.5.8/src/flavors/array.rs:175
#3 0x0000555555570a56 in crossbeam_channel::flavors::array::Channel<usize>::send<usize> (self=0x5555555e2c00, msg=42, deadline=...) at /home/ben/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-channel-0.5.8/src/flavors/array.rs:342
#4 0x000055555556f283 in crossbeam_channel::channel::Sender<usize>::send<usize> (self=0x7fffee3f5b10, msg=42) at /home/ben/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-channel-0.5.8/src/channel.rs:437
#5 0x000055555556ebaa in mpsc_deadlock_reproducer::main::{closure#0} () at src/main.rs:29
#6 0x00005555555760c3 in std::sys_common::backtrace::__rust_begin_short_backtrace<mpsc_deadlock_reproducer::main::{closure_env#0}, ()> (f=...) at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:134
#7 0x000055555556e993 in std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure#0}<mpsc_deadlock_reproducer::main::{closure_env#0}, ()> () at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/thread/mod.rs:526
#8 0x0000555555568713 in core::panic::unwind_safe::{impl#23}::call_once<(), std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<mpsc_deadlock_reproducer::main::{closure_env#0}, ()>> (self=...)
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panic/unwind_safe.rs:271
#9 0x0000555555575886 in std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<mpsc_deadlock_reproducer::main::{closure_env#0}, ()>>, ()> (data=0x7fffee3f5c90)
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485
#10 0x0000555555575adb in __rust_try ()
#11 0x00005555555756ee in std::panicking::try<(), core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<mpsc_deadlock_reproducer::main::{closure_env#0}, ()>>> (f=...)
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449
#12 0x0000555555574243 in std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<mpsc_deadlock_reproducer::main::{closure_env#0}, ()>>, ()> (f=...)
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140
#13 0x000055555556e40c in std::thread::{impl#0}::spawn_unchecked_::{closure#1}<mpsc_deadlock_reproducer::main::{closure_env#0}, ()> () at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/thread/mod.rs:525
#14 0x00005555555645de in core::ops::function::FnOnce::call_once<std::thread::{impl#0}::spawn_unchecked_::{closure_env#1}<mpsc_deadlock_reproducer::main::{closure_env#0}, ()>, ()> () at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250
#15 0x00005555555a1865 in alloc::boxed::{impl#45}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:1973
#16 alloc::boxed::{impl#45}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:1973
#17 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#18 0x00007ffff7d1844b in ?? () from /usr/lib/libc.so.6
#19 0x00007ffff7d9be40 in ?? () from /usr/lib/libc.so.6
Stack trace of receiver:
#0 0x0000555555568587 in crossbeam_utils::backoff::Backoff::spin (self=0x7fffee1f4754) at /home/ben/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-utils-0.8.16/src/backoff.rs:151
#1 0x000055555556fda6 in crossbeam_channel::flavors::array::Channel<usize>::start_recv<usize> (self=0x5555555e2c00, token=0x7fffee1f4828) at /home/ben/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-channel-0.5.8/src/flavors/array.rs:293
#2 0x000055555557102a in crossbeam_channel::flavors::array::Channel<usize>::try_recv<usize> (self=0x5555555e2c00) at /home/ben/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-channel-0.5.8/src/flavors/array.rs:388
#3 0x000055555556f3a5 in crossbeam_channel::channel::Receiver<usize>::try_recv<usize> (self=0x7fffee1f4ba0) at /home/ben/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossbeam-channel-0.5.8/src/channel.rs:761
#4 0x000055555556ecbc in mpsc_deadlock_reproducer::main::{closure#1} () at src/main.rs:46
#5 0x00005555555760d9 in std::sys_common::backtrace::__rust_begin_short_backtrace<mpsc_deadlock_reproducer::main::{closure_env#1}, ()> (f=<error reading variable: Cannot access memory at address 0x2>)
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:134
#6 0x000055555556e9c5 in std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure#0}<mpsc_deadlock_reproducer::main::{closure_env#1}, ()> () at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/thread/mod.rs:526
#7 0x0000555555568768 in core::panic::unwind_safe::{impl#23}::call_once<(), std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<mpsc_deadlock_reproducer::main::{closure_env#1}, ()>> (self=...)
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panic/unwind_safe.rs:271
#8 0x00005555555758fe in std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<mpsc_deadlock_reproducer::main::{closure_env#1}, ()>>, ()> (data=0x7fffee1f4c70)
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485
#9 0x0000555555575adb in __rust_try ()
#10 0x000055555557578e in std::panicking::try<(), core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<mpsc_deadlock_reproducer::main::{closure_env#1}, ()>>> (f=...)
at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449
#11 0x0000555555574256 in std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<mpsc_deadlock_reproducer::main::{closure_env#1}, ()>>, ()> (
f=<error reading variable: Cannot access memory at address 0x2>) at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140
#12 0x000055555556e793 in std::thread::{impl#0}::spawn_unchecked_::{closure#1}<mpsc_deadlock_reproducer::main::{closure_env#1}, ()> () at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/thread/mod.rs:525
#13 0x00005555555645be in core::ops::function::FnOnce::call_once<std::thread::{impl#0}::spawn_unchecked_::{closure_env#1}<mpsc_deadlock_reproducer::main::{closure_env#1}, ()>, ()> () at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250
#14 0x00005555555a1865 in alloc::boxed::{impl#45}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:1973
#15 alloc::boxed::{impl#45}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:1973
#16 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#17 0x00007ffff7d1844b in ?? () from /usr/lib/libc.so.6
#18 0x00007ffff7d9be40 in ?? () from /usr/lib/libc.so.6
from crossbeam.
We've seen this happen as well using Linux (it hangs for ~10 seconds) using try_recv()
. Initially the code we had would do a check for empty and then do recv()
and we noticed that hanging, we found that weird so we switched it to try_recv()
and saw that it behaves the same way.
In our case the sending thread was the same as the receiver thread but an earlier point (I am not sure why the code was written that way tbh...).
from crossbeam.
@rc-andres was your case using a similar thread priority setup?
from crossbeam.
See rust-lang/rust#112723 (comment), I think it's unlikely that try_recv
can be truly non-blocking.
from crossbeam.
Related Issues (20)
- consider adding `is_disconnected` method to Receiver type HOT 1
- Scaling receiver counter up/down based on demand
- `select!` macro and auto-complete HOT 1
- [crossbeam-epoch] false sharing issue for "epoch: AtomicEpoch" field in "Local" struct
- crossbeam-skiplist bug HOT 3
- epoch `fetch_update` not working as expected HOT 2
- Crossbeam channel slower than Go channels with input data delay HOT 5
- Questions about "crossbeam_epoch" HOT 10
- crossbeam channel is very slow if restricted to a single core HOT 4
- Use cfg(target_has_atomic) instead of hard coding which targets support atomics HOT 7
- Donating Funds to Crossbeam HOT 1
- performance issues with memory ordering
- Panicked during `epoch::pin()` HOT 9
- Implement fmt::Display for CachePadded where T: Display HOT 1
- Thread-safe, shared-state concurrency with `WaitGroup` HOT 2
- crossbeam-utils fails to compile on esp32* targets starting Rust 1.74 HOT 3
- provide a scoped thread start taht returns result HOT 1
- Potential to modify the ordering for 'load' operations in the garbage module of branch 0.2.10 HOT 4
- Move CachePadded to separate sub-crate? HOT 5
- Fine-tune the ordering for received HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crossbeam.