Skip to content

[5.7][SourceKit] Guard DependencyStamps with a lock #58850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 12, 2022

  • Explanation: We might run into situations where matchesSourceState reads DependencyStamps while they are being written in buildASTUnit, causing a crash. Guard DependencyStamps by a mutex to avoid this problem. We don’t need to provide any ordering guarantees about whether DependencyStamps have been computed in are accessed because we already assume that the dependencies shouldn't change (much) in the time between an ASTBuildOperation is created and until it produced an AST. I made sure that the mutex can’t introduce deadlocks.
  • Scope: Non code-completion SourceKit requests
  • Risk: Low
  • Issue: rdar://92748564
  • Reviewer: @bnbarham on [SourceKit] Guard DependencyStamps with a lock #58681

We might run into situations where `matchesSourceState` reads `DependencyStamps` while they are being written in `buildASTUnit`, causing a crash.

Guard `DependencyStamps` by a mutex to avoid this problem. We don’t need to provide any ordering guarantees about whether `DependencyStamps` have been computed in are accessed because we already assume that the dependencies shouldn't change (much) in the time between an `ASTBuildOperation` is created and until it produced an AST.

rdar://92748564
@ahoppen ahoppen added the r5.7 label May 12, 2022
@ahoppen ahoppen requested a review from a team as a code owner May 12, 2022 06:17
@ahoppen
Copy link
Member Author

ahoppen commented May 12, 2022

@swift-ci Please test

@ahoppen ahoppen merged commit 327919a into swiftlang:release/5.7 May 13, 2022
@ahoppen ahoppen deleted the pr-5.7/guard-dependency-stamps branch May 13, 2022 16:39
@AnthonyLatsis AnthonyLatsis added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.7 labels Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.7
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants