Skip to content

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 19, 2022

  • Explanation: This fixes a race-conditioned deadlock which could occur while cancelling SourceKit AST build request:
    We have one thread that claimed CancellationRequestCallbackMtx in SwiftASTConsumer::requestCancellation and wants to claim ConsumersAndResultMtx in ASTBuildOperation::requestConsumerCancellation.
    Another thread claimed ConsumersAndResultMtx in ASTBuildOperation::schedule and now wants to claim CancellationRequestCallbackMtx in SwiftASTConsumer::removeCancellationRequestCallback.
    In both cases we could actually release one lock before claiming the other.
  • Scope: SourceKit request handling
  • Risk: Low, just pulls code that doesn’t need a lock out from the lock scope
  • Issue: rdar://90870793
  • Reviewer: @bnbarham on [SourceKit] Resolve a nondeterministic deadlock in SourceKit while cancelling #42258

…ncelling

This fixes a race-conditioned deadlock which could occur while cancelling SourceKit AST build request

We have one thread that claimed `CancellationRequestCallbackMtx` in `SwiftASTConsumer::requestCancellation` and wants to claim `ConsumersAndResultMtx` in `ASTBuildOperation::requestConsumerCancellation`

Another thread claimed `ConsumersAndResultMtx` in `ASTBuildOperation::schedule` and now wants to claim `CancellationRequestCallbackMtx` in `SwiftASTConsumer::removeCancellationRequestCallback`.

In both cases we could actually release one lock before claiming the other.

Fixes rdar://90870793
@ahoppen ahoppen added the r5.7 label May 19, 2022
@ahoppen ahoppen requested a review from airspeedswift May 19, 2022 07:32
@ahoppen ahoppen requested a review from a team as a code owner May 19, 2022 07:32
@ahoppen
Copy link
Member Author

ahoppen commented May 19, 2022

@swift-ci Please test

@ahoppen ahoppen merged commit d53190c into swiftlang:release/5.7 May 30, 2022
@ahoppen ahoppen deleted the pr-5.7/no-deadlock-cancellation branch May 30, 2022 08:55
@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