-
Notifications
You must be signed in to change notification settings - Fork 101
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
h2/fix dropper #1057
h2/fix dropper #1057
Conversation
howardjohn
commented
May 15, 2024
- With compiler bug
- h2: remove drop counter from server
This isn't incremented on the server, and dropping it causes overflow. This is ~fine, but if trace logging is turned on we do a panic-causing overflow (I think only in debug builds?).
} | ||
|
||
impl Drop for H2StreamWriteHalf { | ||
impl Drop for DropCounter { | ||
fn drop(&mut self) { | ||
let mut half_dropped = Arc::new(()); | ||
std::mem::swap(&mut self.half_dropped, &mut half_dropped); | ||
if Arc::into_inner(half_dropped).is_none() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you aren't changing this but it seems like this logic isn't correct... If we get none
back it means we are not the last strong reference so the other half isn't dropped. If we get the inner value back we are the last strong reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we get none back it means we are not the last strong reference so the other half isn't dropped
Otherwise, [None](https://doc.rust-lang.org/std/option/enum.Option.html#variant.None) is returned and the Arc is dropped.
This will succeed even if there are outstanding weak references.
If Arc::into_inner is called on every clone of this Arc, it is guaranteed that exactly one of the calls returns the inner value. This means in particular that the inner value is not dropped.
I think this means that if an atomicbool or some other concrete value is used and wrapped with an Arc
, it should be possible to write this without the swap
, yeah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit is that I'm pretty sure there's a simpler way to do the same thing without the
new + swap
stuff, but that's mostly cosmetic, the fix logic is good.
In response to a cherrypick label: #1057 failed to apply on top of branch "release-1.22":
|
In response to a cherrypick label: new issue created for failed cherrypick: #1064 |