Skip to content
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

FIX: Fix RwLock not treating multiple readers correctly in release mode #170

Merged
merged 4 commits into from
Mar 6, 2025

Conversation

sarsko
Copy link
Contributor

@sarsko sarsko commented Mar 6, 2025

Turns out RwLock doesn't function correctly when run in release mode, as we don't insert to the readers when there already is a reader. This PR fixes that.

Surprised this hasn't been an issue previously, I guess RwLock just isn't used much.

Discovered this when I tried to update the workflow to run the tests in release mode, where some of the RwLock tests failed.

This (and similar issues) might explain the instances where we have seen non-replayable schedules generated in release mode and replayed in debug mode, or vice versa.

I should do a pass and check if all tests replay with schedules created in the opposite mode.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sarsko sarsko mentioned this pull request Mar 6, 2025
@sarsko sarsko enabled auto-merge (squash) March 6, 2025 07:21
@@ -222,7 +222,7 @@ impl<T: ?Sized> RwLock<T> {
state.holder = RwLockHolder::Read(readers);
}
(RwLockType::Read, RwLockHolder::Read(readers)) => {
debug_assert!(readers.insert(me));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch. we need to make sure there's no effectful code inside any debug assertion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, forgot to mention, but I checked that there are no other debug_asserts with effectful code.

@sarsko sarsko merged commit 2a17705 into main Mar 6, 2025
5 checks passed
sarsko added a commit that referenced this pull request Mar 6, 2025
…de (#170)

* FIX: Fix RwLock not treating multiple readers correctly in release mode

* Clippy

* Run tests in release when running workflow

* Reduce dropped_acquire_must_release_random test case count to 1000 (from 10_000)
@sarsko sarsko deleted the RwLock-FIX branch March 6, 2025 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants