Skip to content

hcm: Ensure operations are not called on deleted stream decoders #39346

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

Merged
merged 9 commits into from
May 9, 2025

Conversation

abeyad
Copy link
Contributor

@abeyad abeyad commented May 5, 2025

Previously, it was possible for the ActiveStream in the HttpConnectionManager to get deleted while still trying to process packets from the codec.

This change uses the ActiveStreamHandle with weak pointer semantics to ensure that even with incoming data packets, methods are not called on a deleted ActiveStream, which represents the HCM's RequestDecoder.

Previously, it was possible for the `ActiveStream` in the
`HttpConnectionManager` to get deleted while still trying to process
packets from the codec.

This change uses the `ActiveStreamHandle` with weak pointer semantics to
ensure that even with incoming data packets, methods are not called on a
deleted `ActiveStream`, which represents the HCM's `RequestDecoder`.

Signed-off-by: Ali Beyad <[email protected]>
@abeyad
Copy link
Contributor Author

abeyad commented May 5, 2025

cc @wu-bin

@abeyad
Copy link
Contributor Author

abeyad commented May 6, 2025

/wait

Copy link
Contributor

@KBaichoo KBaichoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this.

IIUC we use the ActiveStreamHandle weak pointer semantics (the shared ptr gets dtored on when the stream is deleted) to check that the HCM ActiveStream is still alive. We only need to do this for server-side streams since it's only an issue with HCM interactions between the two.

A release note in current.yaml is probably worth adding as a bug fix -- and CI is failing.

Otherwise LGTM.

Signed-off-by: Ali Beyad <[email protected]>
@abeyad
Copy link
Contributor Author

abeyad commented May 8, 2025

Thank you for working on this.

IIUC we use the ActiveStreamHandle weak pointer semantics (the shared ptr gets dtored on when the stream is deleted) to check that the HCM ActiveStream is still alive. We only need to do this for server-side streams since it's only an issue with HCM interactions between the two.

A release note in current.yaml is probably worth adding as a bug fix -- and CI is failing.

Otherwise LGTM.

Thanks, added a note to current.yaml.

@yanjunxiang-google
Copy link
Contributor

LGTM modulo CI

abeyad added 3 commits May 8, 2025 15:26
Signed-off-by: Ali Beyad <[email protected]>
Signed-off-by: Ali Beyad <[email protected]>
Signed-off-by: Ali Beyad <[email protected]>
@abeyad
Copy link
Contributor Author

abeyad commented May 8, 2025

Thanks @yanjunxiang-google , all tests are passing now

@abeyad abeyad merged commit b701b03 into envoyproxy:main May 9, 2025
25 checks passed
@abeyad abeyad deleted the hcm-decoder-handle branch May 9, 2025 02:28
fishpan1209 pushed a commit to fishpan1209/envoy that referenced this pull request May 22, 2025
…oyproxy#39346)

Previously, it was possible for the `ActiveStream` in the
`HttpConnectionManager` to get deleted while still trying to process
packets from the codec.

This change uses the `ActiveStreamHandle` with weak pointer semantics to
ensure that even with incoming data packets, methods are not called on a
deleted `ActiveStream`, which represents the HCM's `RequestDecoder`.

---------

Signed-off-by: Ali Beyad <[email protected]>
Signed-off-by: Ting Pan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants