Skip to content

Fix parse cache ref race during cloned program updates#4400

Draft
Copilot wants to merge 9 commits into
mainfrom
copilot/fix-cache-entry-not-found-error
Draft

Fix parse cache ref race during cloned program updates#4400
Copilot wants to merge 9 commits into
mainfrom
copilot/fix-cache-entry-not-found-error

Conversation

Copilot AI commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

A cloned project update can reuse SourceFile pointers after their parse-cache entries were concurrently released by snapshot disposal. Re-refing those reused files with Ref could panic with cache entry not found.

  • Parse cache

    • Added RefValue, which refs an existing entry or restores it from the reused value if it was deleted before the ref.
    • Added RefIfPresent for optional duplicate-source bookkeeping refs.
  • Program clone path

    • Reused source files now restore parse-cache ownership from the SourceFile pointer.
    • Duplicate source entries use optional refs because they only represent previously acquired cache entries and do not carry a restorable SourceFile.
p.host.builder.parseCache.RefValue(
    NewParseCacheKey(file.ParseOptions(), file.Hash, file.ScriptKind),
    file,
)
  • Coverage
    • Added focused refcount cache coverage for restoring a deleted entry without reparsing.

Copilot AI and others added 8 commits June 22, 2026 20:01
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix panic: cache entry not found issue Fix parse cache ref race during cloned program updates Jun 22, 2026
Copilot AI requested a review from DanielRosenwasser June 22, 2026 20:33
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