Skip to content

[Concurrency] Improve assertion to validate we pop the EXACT record we intend to #80522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions stdlib/public/Concurrency/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CancellationNotificationStatusRecord>(swift_task_getCurrent())) {
assert(record == poppedRecord && "The removed record did not match the expected record!");
popStatusRecordOfType<CancellationNotificationStatusRecord>(task)) {
swift_task_dealloc(record);
}
}
Expand Down