Skip to content

fix(xtext.ui): iterate a snapshot of the matches when showing a running search - #1552

Merged
joaodinissf merged 1 commit into
masterfrom
fix/find-references-input-snapshot
Sep 28, 2026
Merged

joaodinissf merged 1 commit into
masterfrom
fix/find-references-input-snapshot

Conversation

@joaodinissf

Copy link
Copy Markdown
Collaborator

Problem

FastReferenceSearchResultContentProvider.inputChanged repopulates the view by iterating the live ReferenceSearchResult.getMatchingReferences() list. That is the internal ArrayList that the search job's accept() appends to without a lock. If a search that is still running is shown, for example re-selected from the search history, the iteration can race the search thread. The ConcurrentModificationException then escapes viewer.setInput(...) and leaves the page half-initialised: the listener is registered, but the view is not populated.

Who is affected: DDK's own languages use Xtext's default content provider, which has the same live iteration. This provider is used by products built on DDK that bind it.

Fix

Iterate a copy (Lists.newArrayList(...)) and skip null elements. The copy itself is unsynchronised, so it can observe a slot the search thread has reserved but not yet published.

This removes the exception. It narrows the race rather than eliminating it: a reference can still be missed or shown twice at the boundary, and the related races in this provider are tracked separately.

Test

FastReferenceSearchResultContentProviderTest is registered in XtextUiTestSuite. A mocked IResourceDescriptions appends a reference to the live list while inputChanged is iterating it, which simulates the search thread deterministically. The test fails on master with ConcurrentModificationException and passes with the fix.

Local run: full mvn clean verify passes apart from failures that also occur on master in this environment; checkstyle and PMD are clean.

Found by the formal models of the find-references batching in #1549 (formal/BUGS.md, REF-2): both the TLA+ and the Lean model reach it, and 3/3 independent reviewers upheld it.

🤖 Generated with Claude Code

…ng search

FastReferenceSearchResultContentProvider.inputChanged iterated the live
getMatchingReferences() list while the search job could still be
appending to it, so re-showing a running search could throw a
ConcurrentModificationException out of setInput and leave the page
half-initialised. Iterate a copy and skip unpublished (null) slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
joaodinissf added a commit that referenced this pull request Sep 26, 2026
formal/README.md describes the method, target status, models and how to
reproduce. formal/BUGS.md catalogues 51 findings (49 confirmed, 1
plausible, 1 refuted) plus 9 observations, all verified by three
independent skeptics, with traces, test status, fix plans, a proposed
fix-PR sequence and links to the fix PRs opened so far (#1550, #1551,
#1552, #1553). REPORT.md is the chronological log of rounds 1-2. The
patches are reference fixes used to show each disabled test turns green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joaodinissf
joaodinissf marked this pull request as ready for review September 28, 2026 22:41
@joaodinissf
joaodinissf merged commit f714d22 into master Sep 28, 2026
4 checks passed
@joaodinissf
joaodinissf deleted the fix/find-references-input-snapshot branch September 28, 2026 22:42
joaodinissf added a commit that referenced this pull request Sep 29, 2026
formal/README.md describes the method, target status, models and how to
reproduce. formal/BUGS.md catalogues 51 findings (49 confirmed, 1
plausible, 1 refuted) plus 9 observations, all verified by three
independent skeptics, with traces, test status, fix plans, a proposed
fix-PR sequence and links to the fix PRs opened so far (#1550, #1551,
#1552, #1553). REPORT.md is the chronological log of rounds 1-2. The
patches are reference fixes used to show each disabled test turns green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants