From 0cb39ddd8a6edaa258a075d7c5577e98dd96be0a Mon Sep 17 00:00:00 2001 From: Konrad 'ktoso' Malawski Date: Fri, 4 Apr 2025 13:25:58 +0900 Subject: [PATCH] [Concurrency] Improve assertion to validate we pop the EXACT record we intend to --- stdlib/public/Concurrency/Task.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stdlib/public/Concurrency/Task.cpp b/stdlib/public/Concurrency/Task.cpp index 1b0de154e2f49..25da2133323ed 100644 --- a/stdlib/public/Concurrency/Task.cpp +++ b/stdlib/public/Concurrency/Task.cpp @@ -1792,9 +1792,11 @@ static void swift_task_removeCancellationHandlerImpl( return; } + auto task = swift_task_getCurrent(); + assert(task->_private()._status().load(std::memory_order_relaxed).getInnermostRecord() == record && + "We expect that the popped record will be exactly first as well as that it is of the expected type"); if (auto poppedRecord = - popStatusRecordOfType(swift_task_getCurrent())) { - assert(record == poppedRecord && "The removed record did not match the expected record!"); + popStatusRecordOfType(task)) { swift_task_dealloc(record); } }