Commit 79a43c0
committed
[SourceKit] Inform consumers about cancellation from a background queue
This fixes a deadlock that could occur when a cursor info request is cancelled while another one is inside the cancellation callback. The schematic deadlock backtrace is
```
sourcekitd::cancelRequest
SourceKit::RequestTracker::cancel -> holds RequestTracker.RequestsMtx
anonymous func in SourceKit::SwiftASTManager::processASTAsync
SourceKit::SwiftASTConsumer::requestCancellation
anonymous func in ASTBuildOperation::addConsumer -> tries to get ASTBuildOperation.ConsumersAndResultMtx
resolveCursor
SourceKit::SwiftASTManager::processASTAsync
SourceKit::SwiftASTConsumer::requestCancellation
anonymous func in ASTBuildOperation::addConsumer
[probably inlined] ASTBuildOperation::requestConsumerCancellation -> holds ASTBuildOperation.ConsumersAndResultMtx
resolveCursor::CursorInfoConsumer::cancelled
anonymous func in SourceKit::SwiftLangSupport::getCursorInfo
anonymous func in handleRequestCursorInfo
reportCursorInfo
anonymous func in sourcekitd::handleRequest -> tries to get RequestTracker.RequestsMtx
```
rdar://1103575021 parent 95ce3d6 commit 79a43c0
1 file changed
+32
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
613 | 613 | | |
614 | 614 | | |
615 | 615 | | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
616 | 623 | | |
617 | 624 | | |
618 | 625 | | |
| |||
782 | 789 | | |
783 | 790 | | |
784 | 791 | | |
785 | | - | |
786 | | - | |
787 | | - | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
788 | 797 | | |
789 | 798 | | |
790 | 799 | | |
| |||
794 | 803 | | |
795 | 804 | | |
796 | 805 | | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | | - | |
801 | | - | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
802 | 817 | | |
803 | 818 | | |
804 | 819 | | |
| |||
950 | 965 | | |
951 | 966 | | |
952 | 967 | | |
953 | | - | |
954 | 968 | | |
955 | 969 | | |
956 | 970 | | |
957 | 971 | | |
958 | 972 | | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
959 | 976 | | |
960 | 977 | | |
961 | 978 | | |
| |||
1027 | 1044 | | |
1028 | 1045 | | |
1029 | 1046 | | |
1030 | | - | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
1031 | 1050 | | |
1032 | 1051 | | |
1033 | 1052 | | |
1034 | | - | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
1035 | 1056 | | |
1036 | 1057 | | |
1037 | 1058 | | |
| |||
0 commit comments