Skip to content

Conversation

@ahoppen
Copy link
Member

@ahoppen ahoppen commented Jun 7, 2023

requestIsEnableBarriers and requestIsBarrier call SKDUIDFromUIdent. What I didn’t know, was that SKDUIDFromUIdent can send XPC requests to the client to translate UIDs via sourcekitd_set_uid_handlers.

Since we were calling requestIsEnableBarriers directly from the XPC server’s main queue, and the UID handler sends an XPC request synchronously, we could get into a deadlock situation.

Immediately jump onto a serial background queue (msgHandlingQueue) in sourcekitdServer_peer_event_handler so that the main queue is free to execute the UID handler. This more closely matches the behavior before I introduced barriers as well, where we were always immediately jumping onto a concurrrent msgHandlingQueue.


I think the best way to review this it to look at the combined diff of #66013 and this PR 208eaac...ahoppen:swift:ahoppen/deadlock#diff-0ef1fa70c987d3bee8fd247f1fe85ca4f3ae5ba089da80000753a9cb503ab269

@ahoppen ahoppen requested review from bnbarham and rintaro as code owners June 7, 2023 23:28
@ahoppen
Copy link
Member Author

ahoppen commented Jun 7, 2023

@swift-ci Please test

Copy link
Contributor

Choose a reason for hiding this comment

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

"message-handling"?

…dent`

`requestIsEnableBarriers` and `requestIsBarrier` call `SKDUIDFromUIdent`. What I didn’t know, was that `SKDUIDFromUIdent` can send XPC requests to the client to translate UIDs via `sourcekitd_set_uid_handlers`.

Since we were calling `requestIsEnableBarriers` directly from the XPC server’s main queue, and the UID handler sends an XPC request synchronously, we could get into a deadlock situation.

Immediately jump onto a serial background queue (`msgHandlingQueue`) in `sourcekitdServer_peer_event_handler` so that the main queue is free to execute the UID handler. This more closely matches the behavior before I introduced barriers as well, where we were always immediately jumping onto a concurrrent `msgHandlingQueue`.
@ahoppen ahoppen force-pushed the ahoppen/deadlock branch from 0a3ddd3 to f0ad258 Compare June 7, 2023 23:33
@ahoppen
Copy link
Member Author

ahoppen commented Jun 7, 2023

@swift-ci Please smoke test

@ahoppen ahoppen merged commit 23e2f34 into swiftlang:main Jun 8, 2023
@ahoppen ahoppen deleted the ahoppen/deadlock branch June 8, 2023 15:56
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