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

h2/fix dropper #1057

Merged
merged 2 commits into from
May 16, 2024
Merged

h2/fix dropper #1057

merged 2 commits into from
May 16, 2024

Conversation

howardjohn
Copy link
Member

  • 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?).
@howardjohn howardjohn requested a review from a team as a code owner May 15, 2024 18:22
@howardjohn howardjohn added release-notes-none Indicates a PR that does not require release notes. cherrypick/release-1.22 Set this label on a PR to auto-merge it to the release-1.22 branch labels May 15, 2024
@istio-testing istio-testing added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 15, 2024
}

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() {
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

@bleggett bleggett left a 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.

@istio-testing istio-testing merged commit f037d39 into istio:master May 16, 2024
3 checks passed
@istio-testing
Copy link
Contributor

In response to a cherrypick label: #1057 failed to apply on top of branch "release-1.22":

Applying: With compiler bug
Using index info to reconstruct a base tree...
A	src/proxy/h2.rs
A	src/proxy/h2/client.rs
A	src/proxy/h2/server.rs
Falling back to patching base and 3-way merge...
Auto-merging src/proxy/h2_client.rs
CONFLICT (content): Merge conflict in src/proxy/h2_client.rs
CONFLICT (modify/delete): src/proxy/h2/server.rs deleted in HEAD and modified in With compiler bug. Version With compiler bug of src/proxy/h2/server.rs left in tree.
CONFLICT (modify/delete): src/proxy/h2/client.rs deleted in HEAD and modified in With compiler bug. Version With compiler bug of src/proxy/h2/client.rs left in tree.
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 With compiler bug
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

@istio-testing
Copy link
Contributor

In response to a cherrypick label: new issue created for failed cherrypick: #1064

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherrypick/release-1.22 Set this label on a PR to auto-merge it to the release-1.22 branch release-notes-none Indicates a PR that does not require release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants