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

Fix memory leak in HTTP request security handshake cancellation #28971

Merged
merged 3 commits into from
Mar 1, 2022

Conversation

apolcyn
Copy link
Contributor

@apolcyn apolcyn commented Feb 24, 2022

The caller of the Handshake API, owns output arguments if the handshake completes successfully. So there's currently a potential race where a handshake completion can be scheduled successfully but the HTTP request is cancelled before the completion runs.

b/220992477

@apolcyn apolcyn added lang/core release notes: no Indicates if PR should not be in release notes release notes: yes Indicates if PR needs to be in release notes and removed release notes: no Indicates if PR should not be in release notes labels Feb 24, 2022
@ctiller
Copy link
Member

ctiller commented Feb 24, 2022

Is there any way we can add a test for this?

@apolcyn
Copy link
Contributor Author

apolcyn commented Feb 24, 2022

Is there any way we can add a test for this?

Outside of finding the right concurrency settings in the test to tickle the race more frequently, we could probably coordinate the race with a mock channel creds. I haven't gotten to that yet but I'll look into that.

@markdroth
Copy link
Member

You probably don't need a mock channel creds, just a mock handshaker. You can register a handshaker directly without going through channel creds (example).

@apolcyn
Copy link
Contributor Author

apolcyn commented Mar 1, 2022

I put together the mock handshake approach, but I realized that the handshake manager also has shutdown logic which needed to be overridden too, in order to trigger the race.

I went with a different approach which I think winds up being simpler. PTAL

Copy link
Member

@markdroth markdroth left a comment

Choose a reason for hiding this comment

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

Looks great!

@apolcyn
Copy link
Contributor Author

apolcyn commented Mar 1, 2022

failures are pre-existing

@apolcyn apolcyn merged commit 20521fb into grpc:master Mar 1, 2022
@copybara-service copybara-service bot added the imported Specifies if the PR has been imported to the internal repository label Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bloat/none imported Specifies if the PR has been imported to the internal repository lang/core perf-change/none release notes: yes Indicates if PR needs to be in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants