Closed GlenDC closed 11 months ago
Note that the second panic message begins with:
thread 'trigger::loom_tests::test_loom_sender_trigger' panicked at 'deadlock; threads = [(Id(0), Blocked(Location(None))), (Id(1), Terminated)]', /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/loom-0.7.0/src/rt/execution.rs:216:13
This indicates thatloom
panicked due to a deadlock in the code under test: either a bug in your code, or in your test.
After this panic occurred, a double-panic occurred while unwinding. This often happens when a Drop
impl does something that requires accessing the loom
test execution state, but the test context has already been torn down. This is kind of an annoying rough edge when using loom
--- we should probably spend some time ensuring that loom
's simulated atomics and synchronization primitives behave more gracefully when used in a Drop
impl during a panic. That would likely require some effort though.
Ok for now going to close the issue then. I haven't found the reason yet, but so far the theory from your end is that it is anyway on my end (whether in the test or actual code). So going to not botter your time more here in that case. If it does end up be a loom issue I'll re-open, but so far it doesn't seem like it is. Thanks!
The double panic is kind of a loom issue, but it's occurring due to a panic from loom correctly detecting a deadlock in your test. So, loom found an issue in your code, and we should fix the double panic so that loom can report these errors better and make them easier to debug :)
Yes I did find the issue in the meanwhile. Turns out I was having a race condition that loom detected which caused me to never wake up... Gosh. Good that i start using loom for these very core primitives of my crate.
I implemented my first (unit) test using Loom:
https://github.com/plabayo/tokio-graceful/blob/41b77187f9fed59fc48074a7256e6f078477f2d4/src/trigger.rs#L223-L237
Problem is however that I get a panic when running it, even when removing most logic I still get the same panic.
This is how I run the test:
as well as:
It panics however. Locally I only get this meaningless error:
Within the CI environment where this test now also runs I do get a better error:
Am I using loom incorrect? Is it not made for these purposes? Do I have a bug in my code? Does documentation need to be updated? no clue. Any help is welcome. I'm also on Tokio's discord as
@glendc
. Available here, but also there.