Filed as FB9486500
Once a local DispatchSemaphore is released by the system, the app crashes in the Xcode 13 beta 5 simulator, but works correctly on the device running iOS 15 beta 5. This is very simple to reproduce.
E.g. adding this on a boilerplate Xcode beta 5 project's VC:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let semaphore = DispatchSemaphore(value: 0)
// If this was a strong instance property the crash does not occur
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
semaphore.signal()
}
DispatchQueue.global().async {
print("Waiting on semaphore...")
semaphore.wait()
print("Semaphore has been signalled, iOS sim will crash about 10 seconds after this message, device will be fine.")
}
}
This issue occurs only on the sim, not a device, on iOS 15 beta 5. In case it's relevant, running on an M1 Mac.
The most critical API affected by this so far is NSFileCoordinator, which totally breaks in the sim when it internally tries to handle semaphores.