-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Channel sending/receiving ends up spinlooping and deadlocking #114851
Comments
probably a duplicate of #112723 though that one is only about |
They look related, but the actual spinning case from their backtrace is different. Ultimately it's not a big problem for us if |
It seems like they're slightly different instances of the general symptom: something is spinning during a priority inversion. With RT scheduling the inversion can last forever. With less strict scheduling it merely takes a while until it resolves. |
@kyrias can you try running your code with the crossbeam-rs/crossbeam#1105 branch of crossbeam to see if that fixes your issue? |
Triage: Can someone provide code to reproduce this issue please? Can the problem still be reproduced? |
We have a system built around an Espressif ESP32-S3 MCU using ESP-IDF/FreeRTOS. Recently when we updated our Rust toolchain we started having issues where under certain conditions the watchdog timer would constantly trigger and reset the system. We've managed to track it down to being caused by the new
crossbeam-channel
-basedChannel
spinlooping intry_send
andtry_recv
.Many parts of our system communicate using
Channel
s and the highest priority threads are the ones that read measurements from sensors and then sends those measurements to various channels for further processing usingtry_send
. These threads also read from command channels usingtry_recv
.Our expectation with this approach is that the sending and receiving from these channels should never block on waiting for other threads to run and if we can't read/send anything right then the methods should immediately return an
Err
which we ignore.Through some judicious
println!
-debugging I've found that when we calltry_send
ortry_recv
we sometimes end up in a situation wherestart_send
/start_recv
performs the followingspin_light
calls multiple thousands of times:rust/library/std/src/sync/mpmc/array.rs
Line 186 in eb26296
rust/library/std/src/sync/mpmc/array.rs
Line 277 in eb26296
This then leads to our idle task never getting to run and thus the watchdog timer times out and resets the system. Disabling the watchdog timer doesn't seem to let it ever get unstuck on its own.
I've tried switching to
crossbeam-channel
as well and while it seems harder to reproduce using that crate it's still happening.Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: