fix(pointer): crash (0xc0000005) when the pointer-capturing component has been unmounted#16337
Open
FaithfulAudio wants to merge 1 commit into
Open
Conversation
…g OnPointerCaptureLost CapturePointer and releasePointerCapture look the capturing component up by its cached m_pointerCapturingComponentTag and dereference the result unguarded. That tag can outlive the component it names: when list/ScrollView virtualization recycles the capturing row mid-pan, componentViewDescriptorWithTag returns a descriptor whose .view is null, so winrt::get_self(...)->OnPointerCaptureLost() dereferences null and terminates the process with 0xc0000005. Null-check targetComponentView at both sites. Skipping the notify loses no state transition: CapturePointer overwrites the stale tag immediately below, and releasePointerCapture clears it via the existing m_capturedPointers.empty() branch. main twin of microsoft#16334 (0.83-stable).
Contributor
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
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.
Problem
A Fabric/Composition app crashes with an access violation (
0xc0000005) during ordinary list interaction on a touch device: pan a virtualized list so the row currently holding pointer capture is recycled, then press or release again.Root cause
Both capture paths in
CompositionEventHandlerlook the capturing component up by its cached tag and dereference the result without checking it:m_pointerCapturingComponentTagcan outlive the component it names. If the capturing component is unmounted without releasing capture — exactly what list/ScrollView virtualization does when it recycles a row mid-pan —componentViewDescriptorWithTagreturns a descriptor whose.viewis null, and the call dereferences it. The same unguarded pattern appears inCapturePointer(when a new capture displaces a previous one) andreleasePointerCapture.Fix
Null-check
targetComponentViewbefore notifying, at both sites. When the view is gone there is nothing to notify —CapturePointeroverwrites the stale tag immediately below, andreleasePointerCaptureclears it via the existingm_capturedPointers.empty()branch. One file, no header or API change.Validation
UseExperimentalNuget=false). Before: panning the FIT inspection list and interacting with a recycled row terminated the process with0xc0000005, reproducibly. After: an automated soak drove the guarded paths with realPT_TOUCHcontacts (InjectTouchInput) — 10 press-a-row-then-pan-far-while-held events (the exact recycle-under-capture sequence), plus expand/collapse mount churn and hard flicks — with no crash and the process responsive throughout./azp run), and I have not builtmainwith this change. The guard is context-adapted tomain(m_capturedPointers.insert/.empty()), diff verified againstmainatc69cf55.Caveats for reviewers:
maintwin of fix(pointer): crash (0xc0000005) when the pointer-capturing component has been unmounted #16334 (0.83-stable), per the twin convention from fix(textinput): correct placeholder layout constraints (px vs DIP) and no-op NaN fontSize guard #16303/fix(textinput): correct placeholder layout constraints (px vs DIP) and no-op NaN fontSize guard #16317.OnPointerCaptureLost. If you would rather RNW proactively released capture in the component teardown path so the tag can never go stale, that is a larger but arguably more correct fix and I am happy to take that direction instead.type: prerelease; happy to adjust.🤖 Generated with Claude Code
Microsoft Reviewers: Open in CodeFlow