You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have review the following code for a lot times:
the code position: /library/std/src/sys/unix/locks/futex_rwlock.rs : line 212
fnwrite_contended(&self){
...
...
let s = self.state.load(Relaxed);// I guess "is_unlocked(state)" should be "is_unlocked(s)"// because here "state" should be locked // and the code should test "s" for the current statusifis_unlocked(state) || !has_writers_waiting(s){
state = s;continue;}
...
...}
the code should test the current "self.state" again to avoid unlock write. but "state" is old and is tested. I can not get what it does.
Fix typo in futex RwLock::write_contended.
I wrote `state` where I should've used `s`.
This was spotted by `@Warrenren.`
This change removes the unnecessary `s` variable to prevent that mistake.
Fortunately, this typo didn't affect the correctness of the lock, as the
second half of the condition (!has_writers_waiting) is enough for
correctness, which explains why this mistake didn't show up during
testing.
Fixesrust-lang/rust#97162
I have review the following code for a lot times:
the code position: /library/std/src/sys/unix/locks/futex_rwlock.rs : line 212
the code should test the current "self.state" again to avoid unlock write. but "state" is old and is tested. I can not get what it does.
Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: