Commit efc5e56
committed
[SourceKit] Resolve a nondeterministic deadlock in SourceKit while cancelling
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://908707931 parent 8b19bae commit efc5e56
1 file changed
+21
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1150 | 1150 | | |
1151 | 1151 | | |
1152 | 1152 | | |
| 1153 | + | |
1153 | 1154 | | |
1154 | 1155 | | |
1155 | 1156 | | |
1156 | 1157 | | |
1157 | | - | |
1158 | | - | |
1159 | | - | |
| 1158 | + | |
1160 | 1159 | | |
1161 | 1160 | | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
1162 | 1164 | | |
1163 | 1165 | | |
1164 | 1166 | | |
1165 | 1167 | | |
1166 | 1168 | | |
1167 | 1169 | | |
1168 | | - | |
1169 | | - | |
1170 | | - | |
1171 | | - | |
1172 | | - | |
1173 | | - | |
1174 | | - | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
1175 | 1179 | | |
1176 | | - | |
1177 | 1180 | | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
1183 | | - | |
1184 | 1181 | | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
1185 | 1189 | | |
1186 | 1190 | | |
1187 | 1191 | | |
| |||
0 commit comments