Skip to content

Commit 0cb39dd

Browse files
committed
[Concurrency] Improve assertion to validate we pop the EXACT record we intend to
1 parent 562d7dc commit 0cb39dd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

stdlib/public/Concurrency/Task.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,9 +1792,11 @@ static void swift_task_removeCancellationHandlerImpl(
17921792
return;
17931793
}
17941794

1795+
auto task = swift_task_getCurrent();
1796+
assert(task->_private()._status().load(std::memory_order_relaxed).getInnermostRecord() == record &&
1797+
"We expect that the popped record will be exactly first as well as that it is of the expected type");
17951798
if (auto poppedRecord =
1796-
popStatusRecordOfType<CancellationNotificationStatusRecord>(swift_task_getCurrent())) {
1797-
assert(record == poppedRecord && "The removed record did not match the expected record!");
1799+
popStatusRecordOfType<CancellationNotificationStatusRecord>(task)) {
17981800
swift_task_dealloc(record);
17991801
}
18001802
}

0 commit comments

Comments
 (0)