diff options
| author | Connor Tsui <connor.tsui20@gmail.com> | 2024-11-08 18:13:18 -0500 |
|---|---|---|
| committer | Connor Tsui <connor.tsui20@gmail.com> | 2024-11-16 12:31:14 -0500 |
| commit | 84fd95cbedf1e1c1826e378ffc4d1a3d335deff4 (patch) | |
| tree | 5f64286c72d130d9ca619bfc326066f8c596024d /library/std/src/sys/sync | |
| parent | 3d191b50d2b5a4b17eda2f8cccaa5088ef56b8af (diff) | |
| download | rust-84fd95cbedf1e1c1826e378ffc4d1a3d335deff4.tar.gz rust-84fd95cbedf1e1c1826e378ffc4d1a3d335deff4.zip | |
fix memory ordering bug + bad test
This commit fixes a memory ordering bug in the futex implementation (`Relaxed` -> `Release` on `downgrade`). This commit also removes a badly written test that deadlocked and replaces it with a more reasonable test based on an already-tested `downgrade` test from the parking-lot crate.
Diffstat (limited to 'library/std/src/sys/sync')
| -rw-r--r-- | library/std/src/sys/sync/rwlock/futex.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/std/src/sys/sync/rwlock/futex.rs b/library/std/src/sys/sync/rwlock/futex.rs index e0f4a91e073..961819cae8d 100644 --- a/library/std/src/sys/sync/rwlock/futex.rs +++ b/library/std/src/sys/sync/rwlock/futex.rs @@ -195,7 +195,7 @@ impl RwLock { #[inline] pub unsafe fn downgrade(&self) { // Removes all write bits and adds a single read bit. - let state = self.state.fetch_add(DOWNGRADE, Relaxed); + let state = self.state.fetch_add(DOWNGRADE, Release); debug_assert!(is_write_locked(state), "RwLock must be write locked to call `downgrade`"); if has_readers_waiting(state) { |
