Skip to content

Skip folded and moved results when folding non-primary matches - #6

Closed
Tom Plant (pl4nty) wants to merge 2 commits into
masterfrom
claude/winget-cli-issue-6624-7vq9ig
Closed

Tom Plant (pl4nty) wants to merge 2 commits into
masterfrom
claude/winget-cli-issue-6624-7vq9ig

Conversation

@pl4nty

Copy link
Copy Markdown
Member

📖 Description

FoldResults builds its candidate list from NonPrimaryPackageIndices. Those lists aren't updated after the folds, so they can point at stale entries:

  • An entry that already folded into a primary match has a null Package. It's still a candidate for its other available packages, so a later entry dereferences it and crashes (c0000005).
  • If the primary match comes later in the list, it gets moved into the folded entry's index. That index is still a candidate, so a later entry with the same number of available packages folds the tracked package into itself. Instead of a crash, winget list shows a wrong result.

This PR skips both kinds of candidate when filtering candidateMatches.

🔗 References

Fixes microsoft#6624
Originally reported by KarbitsCode (@KarbitsCode) in pl4nty/winget-extras#2428

🔍 Validation

Added CompositeSource_SxS_FoldedResultIsNonPrimaryCandidate, which follows the repro in the issue. It has one section for each order: the tracked result first (the crash), and the tracked result moved forward (the wrong fold).

Before the fix (Debug x64, test only):

CompositeSource.cpp(2116): FAILED:
due to a fatal error condition:
  SIGSEGV - Segmentation violation signal
-c "Tracked result moved forward"
CompositeSource.cpp(2131): FAILED:
  REQUIRE( result.Matches.size() == 2 )
with expansion:
  1 == 2

After the fix:

AppInstallerCLITests.exe CompositeSource_SxS_FoldedResultIsNonPrimaryCandidate
All tests passed (20 assertions in 1 test case)

AppInstallerCLITests.exe [CompositeSource]
All tests passed (807 assertions in 49 test cases)

AppInstallerCLITests.exe [UpdateFlow],[ListFlow],[SearchFlow]
All tests passed (144 assertions in 38 test cases)

✅ Checklist

🤖 AI Assistance

  • AI assistance was used and has been disclosed in this PR
  • No AI assistance was used

📋 Issue Type

  • Bug fix
  • Feature
  • Task

Generated by Claude Code

FoldResults could pick a candidate index whose result had already been
folded into a primary match, dereferencing its null Package. It could
also pick an index that a later primary result had been moved into,
folding the tracked package into an unrelated result.

Fixes microsoft#6624

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GS4h7Zmyh2QsoqHXHARQjX
@github-actions

This comment has been minimized.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GS4h7Zmyh2QsoqHXHARQjX
@pl4nty
Tom Plant (pl4nty) deleted the claude/winget-cli-issue-6624-7vq9ig branch October 24, 2026 07:19
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.

winget list/upgrade crash when a folded match is still a non-primary candidate

2 participants