Skip to content

Fix race when copying lazy computed values for updateProgram#2702

Open
sheetalkamat wants to merge 3 commits intomainfrom
ataRace
Open

Fix race when copying lazy computed values for updateProgram#2702
sheetalkamat wants to merge 3 commits intomainfrom
ataRace

Conversation

@sheetalkamat
Copy link
Member

Fixes #2275

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a reported data race (#2275) in the TypeScript-go compiler’s Program cloning path (updateProgram/UpdateProgram) by making certain lazily computed caches safe to copy across program updates.

Changes:

  • Introduced a generic lazyValue[T] helper to safely manage lazily computed cached values with a “try-get-if-initialized” path.
  • Updated Program to store unresolvedImports and knownSymlinks using lazyValue, and adjusted GetUnresolvedImports/GetSymlinkCache accordingly.
  • Modified UpdateProgram to copy only fully-initialized cached values for these fields, avoiding concurrent reads of partially initialized state.

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.

Race condition detected between program updates and ATA(?)

2 participants