Skip to content

Revert "Concurrency: remove workaround for silencing UB" #80421

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 3, 2025
Merged
Show file tree
Hide file tree
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
10 changes: 6 additions & 4 deletions stdlib/public/Concurrency/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "swift/Runtime/EnvironmentVariables.h"
#include "swift/Runtime/HeapObject.h"
#include "swift/Runtime/Heap.h"
#include "swift/Runtime/STLCompatibility.h"
#include "swift/Threading/Mutex.h"
#include <atomic>
#include <new>
Expand Down Expand Up @@ -1059,6 +1058,8 @@ swift_task_create_commonImpl(size_t rawTaskCreateFlags,
// Initialize the parent context pointer to null.
initialContext->Parent = nullptr;

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-function-type-mismatch"
// Initialize the resumption funclet pointer (async return address) to
// the final funclet for completing the task.

Expand All @@ -1072,20 +1073,21 @@ swift_task_create_commonImpl(size_t rawTaskCreateFlags,
// The final funclet shouldn't release the task or the task function.
} else if (asyncLet) {
initialContext->ResumeParent =
std::bit_cast<TaskContinuationFunction *>(&completeTask);
reinterpret_cast<TaskContinuationFunction*>(&completeTask);

// If we have a non-null closure context and the task function is not
// consumed by calling it, use a final funclet that releases both the
// task and the closure context.
} else if (closureContext && !taskCreateFlags.isTaskFunctionConsumed()) {
initialContext->ResumeParent =
std::bit_cast<TaskContinuationFunction *>(&completeTaskWithClosure);
reinterpret_cast<TaskContinuationFunction*>(&completeTaskWithClosure);

// Otherwise, just release the task.
} else {
initialContext->ResumeParent =
std::bit_cast<TaskContinuationFunction *>(&completeTaskAndRelease);
reinterpret_cast<TaskContinuationFunction*>(&completeTaskAndRelease);
}
#pragma clang diagnostic pop

// Initialize the task-local allocator and our other private runtime
// state for the task.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
// DEP: _exit
// DEP: _free
// DEP: _malloc
// DEP: _memcpy
// DEP: _memmove
// DEP: _memset
// DEP: _memset_s
Expand Down
1 change: 0 additions & 1 deletion test/embedded/dependencies-concurrency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
// DEP: _exit
// DEP: _free
// DEP: _malloc
// DEP: _memcpy
// DEP: _memmove
// DEP: _memset
// DEP: _memset_s
Expand Down
1 change: 0 additions & 1 deletion test/embedded/dependencies-concurrency2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// DEP: _exit
// DEP: _free
// DEP: _malloc
// DEP: _memcpy
// DEP: _memmove
// DEP: _memset
// DEP: _memset_s
Expand Down