Skip to content

Commit b788dd1

Browse files
committed
[Concurrency] TaskExecutors may be non-swift objects; dont swift_release them
Since we introduced proper ownership of task executors, they are now released and retained. The problem appears with a dispatch_queue_t which conforms to TaskExecutor being passed to Task initializer and retains work okey because it is __owned. However, upon destroy we swift_released the executor reference, which is incorrect as we must be using object specific release methods -- in this case the safe way to support all kinds of objects is `swift_unknownObjectRelease` resolves rdar://131151645
1 parent 82dd1b9 commit b788dd1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

stdlib/public/Concurrency/TaskStatus.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,11 @@ void AsyncTask::dropInitialTaskExecutorPreferenceRecord() {
772772
//
773773
// This should not be done for withTaskExecutorPreference executors,
774774
// however in that case, we would not enter this function here to clean up.
775-
swift_release(executorIdentityToRelease);
775+
//
776+
// NOTE: This MUST NOT assume that the object is a swift object (and use
777+
// swift_release), because a dispatch_queue_t conforms to TaskExecutor,
778+
// and may be passed in here; in which case swift_releasing it would be incorrect.
779+
swift_unknownObjectRelease(executorIdentityToRelease);
776780
}
777781

778782
/**************************************************************************/

0 commit comments

Comments
 (0)