tokio-rs / loom

Concurrency permutation testing tool for Rust.
MIT License
2.14k stars 111 forks source link

fix double panic when exceeding the branch limit in `Drop` #245

Closed hawkw closed 2 years ago

hawkw commented 2 years ago

Loom will panic if the maximum number of branches is exceeded. If a type's Drop impl performs a branch (for example, a MutexGuard or Arc, or a user-defined type that performs atomic operations in its Drop impl), we will hit the assertion a second time, resulting in a double panic. This sucks, because it makes these test failures much harder to debug.

This branch fixes the issue by changing the assertion checking path length to also check if the current thread is panicking. If we're already panicking, we don't make the assertion, to avoid causing a double panic. I've added a test that reproduces this double panic, as well.

I've also fixed a typo in the assertion message. :)

Signed-off-by: Eliza Weisman eliza@buoyant.io