From 50566947e98ea845030cfa3b4c199fb9a2052d53 Mon Sep 17 00:00:00 2001 From: Sam McCall Date: Fri, 2 Jul 2021 15:55:43 +0200 Subject: [PATCH] [clangd] Fix possible assertion fail in TUScheduler BlockUntilIdle is supposed to return false if it fails. If an intermediate step fails to clear the queue, we shouldn't charge ahead and assert on the state of the queue. --- clang-tools-extra/clangd/TUScheduler.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/clangd/TUScheduler.cpp b/clang-tools-extra/clangd/TUScheduler.cpp index 09c68a3..05ce4f9 100644 --- a/clang-tools-extra/clangd/TUScheduler.cpp +++ b/clang-tools-extra/clangd/TUScheduler.cpp @@ -1380,11 +1380,13 @@ bool ASTWorker::blockUntilIdle(Deadline Timeout) const { }; // Make sure ASTWorker has processed all requests, which might issue new // updates to PreamblePeer. - WaitUntilASTWorkerIsIdle(); + if (WaitUntilASTWorkerIsIdle()) + return false; // Now that ASTWorker processed all requests, ensure PreamblePeer has served // all update requests. This might create new PreambleRequests for the // ASTWorker. - PreamblePeer.blockUntilIdle(Timeout); + if (!PreamblePeer.blockUntilIdle(Timeout)) + return false; assert(Requests.empty() && "No new normal tasks can be scheduled concurrently with " "blockUntilIdle(): ASTWorker isn't threadsafe"); -- 2.7.4