From 9145e5823ea1af98ef31709d0a1a4a3836f65898 Mon Sep 17 00:00:00 2001 From: Robert Connell Date: Wed, 10 Dec 2025 13:58:52 -0500 Subject: [PATCH] Ensure call to unsafe_await is not called from Swifts concurrency system --- Sources/Basics/Concurrency/ConcurrencyHelpers.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/Basics/Concurrency/ConcurrencyHelpers.swift b/Sources/Basics/Concurrency/ConcurrencyHelpers.swift index 2837bea4b95..ad6513f0add 100644 --- a/Sources/Basics/Concurrency/ConcurrencyHelpers.swift +++ b/Sources/Basics/Concurrency/ConcurrencyHelpers.swift @@ -27,6 +27,12 @@ public enum Concurrency { @available(*, noasync, message: "This method blocks the current thread indefinitely. Calling it from the concurrency pool can cause deadlocks") public func unsafe_await(_ body: @Sendable @escaping () async -> T) -> T { + withUnsafeCurrentTask { task in + if task != nil { + fatalError("This function must not be invoked from the Swift Concurrency thread pool.") + } + } + let semaphore = DispatchSemaphore(value: 0) let box = ThreadSafeBox()