Skip to content

Commit 8d72db5

Browse files
authored
Merge pull request #80522 from ktoso/wip-better-assertion-pop-record
[Concurrency] Improve assertion to validate we pop the EXACT record we intend to
2 parents 50ea777 + 0cb39dd commit 8d72db5

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
@@ -1794,9 +1794,11 @@ static void swift_task_removeCancellationHandlerImpl(
17941794
return;
17951795
}
17961796

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

0 commit comments

Comments
 (0)