From 7cd49372904b8a89e829de75ad195d104cd0f204 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Mon, 4 Apr 2022 11:31:55 -0700 Subject: [PATCH] [SourceKit] Disable cancellation of in-flight non-completion requests We need to run SILGen for diagnostics (to actually get all diagnostics). All non-completion requests share an AST and thus they too run SILGen. Any lazy typechecking run in SILGen assumes that it succeeds. Cancellation can cause typechecking to fail here though, since we simply check the flag and error if it's set. This unfortunately has the ability to cause any any number of crashes since various invariants in SILGen are then broken. Disable cancellation of in-flight non-completion requests for now until we have a proper fix in place. Resolves rdar://91251017. --- tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp | 1 - unittests/SourceKit/SwiftLang/CursorInfoTest.cpp | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp b/tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp index b99647f2f0b5a..c8c670710ac60 100644 --- a/tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp +++ b/tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp @@ -1054,7 +1054,6 @@ ASTUnitRef ASTBuildOperation::buildASTUnit(std::string &Error) { Error = "compilation setup failed"; return nullptr; } - CompIns.getASTContext().CancellationFlag = CancellationFlag; registerIDERequestFunctions(CompIns.getASTContext().evaluator); if (TracedOp.enabled()) { TracedOp.start(TraceInfo); diff --git a/unittests/SourceKit/SwiftLang/CursorInfoTest.cpp b/unittests/SourceKit/SwiftLang/CursorInfoTest.cpp index 8fab952adc88d..3f6b764ee1eae 100644 --- a/unittests/SourceKit/SwiftLang/CursorInfoTest.cpp +++ b/unittests/SourceKit/SwiftLang/CursorInfoTest.cpp @@ -417,7 +417,8 @@ TEST_F(CursorInfoTest, CursorInfoMustWaitDueTokenRace) { EXPECT_EQ(strlen("fog"), Info.Length); } -TEST_F(CursorInfoTest, CursorInfoCancelsPreviousRequest) { +// Disabled until we re-enable cancellation (rdar://91251055) +TEST_F(CursorInfoTest, DISABLED_CursorInfoCancelsPreviousRequest) { // TODO: This test case relies on the following snippet being slow to type // check so that the first cursor info request takes longer to execute than it // takes time to schedule the second request. If that is fixed, we need to @@ -467,7 +468,8 @@ TEST_F(CursorInfoTest, CursorInfoCancelsPreviousRequest) { llvm::report_fatal_error("Did not receive a resonse for the first request"); } -TEST_F(CursorInfoTest, CursorInfoCancellation) { +// Disabled until we re-enable cancellation (rdar://91251055) +TEST_F(CursorInfoTest, DISABLED_CursorInfoCancellation) { // TODO: This test case relies on the following snippet being slow to type // check so that the first cursor info request takes longer to execute than it // takes time to schedule the second request. If that is fixed, we need to