You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asyncband.apache.org by "orthur2 (via GitHub)" <gi...@apache.org> on 2026/10/11 16:04:49 UTC

[PR] fix(rwlock): remove downgrade from mapped write guards [asyncband]

orthur2 opened a new pull request, #365:
URL: https://github.com/apache/asyncband/pull/365

   ## Summary
   
   Closes #362.
   
   Remove `MappedRwLockWriteGuard::downgrade` and `OwnedMappedRwLockWriteGuard::downgrade`, which are unsound. They were added in #65, first shipped in mea 0.4.2, and are still in 0.7.3. To keep shared access to a component, downgrade the original write guard first and then map it with `RwLockReadGuard::map` or `OwnedRwLockReadGuard::map`. The docs and the changelog describe this migration.
   
   ## Design Notes
   
   The projection of a mapped write guard can go through interior mutability using exclusive access, as `Mutex::get_mut` does. After a downgrade, another reader can lock the same mutex and change that data while the guard still hands out `&U`. With a `RefCell<Box<_>>` it is even a use-after-free in single-threaded safe code. No bound on the types rules this out, and keeping the write permits would make the method pointless, so this follows tokio and lock_api in not offering it. A `downgrade_map` taking `FnOnce(&T) -> &U` would only shorten the migration above, so it can wait until someone needs it. The reproducers and discussion are in #358 and #362.
   
   Two compile-fail doctests keep the removed methods from coming back. Two Miri tests in `unsafe_paths_test` take the migration path while a second reader locks a mutex inside the projection. No other Miri test keeps a projected read guard alive while another reader uses the lock, so these would catch a read projection derived through `&mut`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org


Re: [PR] fix(rwlock): remove downgrade from mapped write guards [asyncband]

Posted by "jeffoodchain (via GitHub)" <gi...@apache.org>.
jeffoodchain commented on PR #365:
URL: https://github.com/apache/asyncband/pull/365#issuecomment-6111176191

   yes ofc, would be happy to review. I will do this tomorrow. 🙏


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org


Re: [PR] fix(rwlock): remove downgrade from mapped write guards [asyncband]

Posted by "orthur2 (via GitHub)" <gi...@apache.org>.
orthur2 commented on PR #365:
URL: https://github.com/apache/asyncband/pull/365#issuecomment-6111106328

   @jeffoodchain @Soumya2004-java could you take a look when you have time? 
   
   GitHub only lets me request reviews from collaborators, so I couldn’t add you as reviewers, but you can still leave a review on the PR directly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org


Re: [PR] fix(rwlock): remove downgrade from mapped write guards [asyncband]

Posted by "QwQBiG (via GitHub)" <gi...@apache.org>.
QwQBiG commented on code in PR #365:
URL: https://github.com/apache/asyncband/pull/365#discussion_r4255252964


##########
CHANGELOG.md:
##########
@@ -23,6 +23,10 @@ All notable changes to this project will be documented in this file.
 
 ## Unreleased
 
+### Breaking changes

Review Comment:
   A separate PR for 0.7.4 sounds good to me, thanks! And I'll review it; we can keep #365 for after the release.    
   
   @tisonkun, I'd value your input.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org


Re: [PR] fix(rwlock): remove downgrade from mapped write guards [asyncband]

Posted by "jeffoodchain (via GitHub)" <gi...@apache.org>.
jeffoodchain commented on code in PR #365:
URL: https://github.com/apache/asyncband/pull/365#discussion_r4273913808


##########
CHANGELOG.md:
##########
@@ -23,6 +23,10 @@ All notable changes to this project will be documented in this file.
 
 ## Unreleased
 
+### Breaking changes

Review Comment:
   Since the 0.7.4 release is already underway, I'll skip the deprecation PR. Merging #365 after 0.7.4 sounds good to me.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org


Re: [PR] fix(rwlock): remove downgrade from mapped write guards [asyncband]

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun merged PR #365:
URL: https://github.com/apache/asyncband/pull/365


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org


Re: [PR] fix(rwlock): remove downgrade from mapped write guards [asyncband]

Posted by "Soumya2004-java (via GitHub)" <gi...@apache.org>.
Soumya2004-java commented on PR #365:
URL: https://github.com/apache/asyncband/pull/365#issuecomment-6112002696

   I reviewed the fix and it looks good to me. Removing both methods seems to address the issue, and the migration approach makes sense.
   
   I saw the discussion about releasing v0.7.4 before merging this breaking change. That sounds reasonable.
   
   I couldn't run the full test suite locally because Cargo couldn't resolve the crates.io download host, so I haven't independently verified the new tests under Miri.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org


Re: [PR] fix(rwlock): remove downgrade from mapped write guards [asyncband]

Posted by "orthur2 (via GitHub)" <gi...@apache.org>.
orthur2 commented on PR #365:
URL: https://github.com/apache/asyncband/pull/365#issuecomment-6123817270

   @jeffoodchain Updated the new docs and both deref SAFETY comments as suggested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org


Re: [PR] fix(rwlock): remove downgrade from mapped write guards [asyncband]

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on code in PR #365:
URL: https://github.com/apache/asyncband/pull/365#discussion_r4242260459


##########
CHANGELOG.md:
##########
@@ -23,6 +23,10 @@ All notable changes to this project will be documented in this file.
 
 ## Unreleased
 
+### Breaking changes

Review Comment:
   I'm considering to release a 0.7.4 recently to include fixes like #361 
   
   Then we will merge this PR that includes breaking changes.
   
   @QwQBiG do you happen to have some time the following week to handle this?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org


Re: [PR] fix(rwlock): remove downgrade from mapped write guards [asyncband]

Posted by "orthur2 (via GitHub)" <gi...@apache.org>.
orthur2 commented on code in PR #365:
URL: https://github.com/apache/asyncband/pull/365#discussion_r4242282501


##########
CHANGELOG.md:
##########
@@ -23,6 +23,10 @@ All notable changes to this project will be documented in this file.
 
 ## Unreleased
 
+### Breaking changes

Review Comment:
   Sounds good. @QwQBiG, the release skill covers the whole process, from the tracking issue through the ATR vote to publication. Feel free to ask me if anything is unclear. I went through it for 0.7.3.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org


Re: [PR] fix(rwlock): remove downgrade from mapped write guards [asyncband]

Posted by "QwQBiG (via GitHub)" <gi...@apache.org>.
QwQBiG commented on code in PR #365:
URL: https://github.com/apache/asyncband/pull/365#discussion_r4245734330


##########
CHANGELOG.md:
##########
@@ -23,6 +23,10 @@ All notable changes to this project will be documented in this file.
 
 ## Unreleased
 
+### Breaking changes

Review Comment:
   Sure, I can handle the 0.7.4 release. I'll confirm the release scope and follow the release skill.
   
   Thanks @orthur2 for offering to help! 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org


Re: [PR] fix(rwlock): remove downgrade from mapped write guards [asyncband]

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on code in PR #365:
URL: https://github.com/apache/asyncband/pull/365#discussion_r4257479886


##########
CHANGELOG.md:
##########
@@ -23,6 +23,10 @@ All notable changes to this project will be documented in this file.
 
 ## Unreleased
 
+### Breaking changes

Review Comment:
   Either deprecating these methods or just merge #365 after 0.7.4 should be OK.
   
   If anyone would like to send a deprecation PR, feel free to do :D



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org


Re: [PR] fix(rwlock): remove downgrade from mapped write guards [asyncband]

Posted by "QwQBiG (via GitHub)" <gi...@apache.org>.
QwQBiG commented on PR #365:
URL: https://github.com/apache/asyncband/pull/365#issuecomment-6122295331

   +1 LGTM
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org


Re: [PR] fix(rwlock): remove downgrade from mapped write guards [asyncband]

Posted by "jeffoodchain (via GitHub)" <gi...@apache.org>.
jeffoodchain commented on code in PR #365:
URL: https://github.com/apache/asyncband/pull/365#discussion_r4245046296


##########
CHANGELOG.md:
##########
@@ -23,6 +23,10 @@ All notable changes to this project will be documented in this file.
 
 ## Unreleased
 
+### Breaking changes

Review Comment:
   sorry I actually don't know much related to the releasing process. But I think it would be better to add a flag like `#[deprecated(note = "unsound, fixed in #365")]`? (just to avoid the bug from releasing)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org


Re: [PR] fix(rwlock): remove downgrade from mapped write guards [asyncband]

Posted by "orthur2 (via GitHub)" <gi...@apache.org>.
orthur2 commented on code in PR #365:
URL: https://github.com/apache/asyncband/pull/365#discussion_r4247833487


##########
CHANGELOG.md:
##########
@@ -23,6 +23,10 @@ All notable changes to this project will be documented in this file.
 
 ## Unreleased
 
+### Breaking changes

Review Comment:
   Good idea. A deprecation warning in 0.7.4 would point users at the migration before the methods go away. I’d put the migration in the note instead of a PR number, since that’s what users can act on, e.g. “downgrade the original write guard, then map the read guard”. 
   
   @QwQBiG @tisonkun should I send a small PR for 0.7.4 that deprecates both methods, or would you rather handle it as part of the release?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org