LifetimeManager: guard s_OnTimeout against unmatched timer fires#40449
Open
LifetimeManager: guard s_OnTimeout against unmatched timer fires#40449
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a race in LifetimeManager::s_OnTimeout where an unmatched timer fire could cause m_lastTimerWait to be overwritten with nullptr, breaking the destructor’s “wait for pending callbacks” guarantee in the WSL Windows service lifetime tracking.
Changes:
- Guarded the timer
release()/reset()/swap()sequence so it only runs when the timed-out callback entry was actually found (i.e.,clientLocal.timeris non-null). - Added an explanatory comment documenting why the guard is needed.
8880f27 to
8fe54d6
Compare
When the timer callback runs but find_if doesn't match (because the entry was already removed and recreated by RefreshClientCallback or similar), clientLocal stays default-constructed with a null timer. The unconditional .release()/.swap() then clobbers any previously stashed m_lastTimerWait with null, breaking the destructor's wait guarantee. Skip the swap when there is no timer to stash. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8fe54d6 to
ef105d3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If the timer fires but
find_ifdoesn't match (entry erased, or replaced by the retry path),clientLocalis default-constructed and the unconditional swap clobbersm_lastTimerWaitwith null - breaking the destructor's wait-for-pending-callbacks guarantee.Guard the swap so an unmatched fire is a no-op.