Skip to content

[EventEngine] Fix a potential use-after-free error on Windows#42078

Closed
murgatroid99 wants to merge 3 commits into
grpc:masterfrom
murgatroid99:windows_event_engine_race_fix_2
Closed

[EventEngine] Fix a potential use-after-free error on Windows#42078
murgatroid99 wants to merge 3 commits into
grpc:masterfrom
murgatroid99:windows_event_engine_race_fix_2

Conversation

@murgatroid99

Copy link
Copy Markdown
Member

This issue was introduced by #41563. That PR allowed OnConnectCompleted to proceed past a failed Cancel(state->timer_handle()), and the next line releases the timer callback. That is a problem because the timer callback can still run, though it won't actually do anything beyond see that the OnConnectedCallback ran and then release itself. The solution is to only release the timer callback if the timer was successfully cancelled, and otherwise count on the timer callback to clean itself up.

OnConnectCallback doesn't interact with the timer after that point, so I'm fairly certain that this is the last problem of its kind here.

@murgatroid99 murgatroid99 requested a review from markdroth April 10, 2026 19:02
@murgatroid99 murgatroid99 added lang/core release notes: yes Indicates if PR needs to be in release notes labels Apr 10, 2026
@copybara-service copybara-service Bot closed this in 76841c6 May 5, 2026
asheshvidyut pushed a commit to a-detiste/grpc that referenced this pull request Jun 10, 2026
…2078)

This issue was introduced by grpc#41563. That PR allowed `OnConnectCompleted` to proceed past a failed `Cancel(state->timer_handle())`, and the next line releases the timer callback. That is a problem because the timer callback can still run, though it won't actually do anything beyond see that the `OnConnectedCallback` ran and then release itself. The solution is to only release the timer callback if the timer was successfully cancelled, and otherwise count on the timer callback to clean itself up.

`OnConnectCallback` doesn't interact with the timer after that point, so I'm fairly certain that this is the last problem of its kind here.

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes grpc#42078

COPYBARA_INTEGRATE_REVIEW=grpc#42078 from murgatroid99:windows_event_engine_race_fix_2 ec74a2e
PiperOrigin-RevId: 910905066
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants