mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The introduction of the library providing back-deployment fixes for Swift 5.6 concurrency libraries (and older) introduced a concurrency crash in the following OS version ranges - macOS [12.0, 12.1) - iOS [15.0, 15.1) - tvOS [15.0, 15.1) - watchOS [8.0, 8.2) Neither older nor newer versions of the listed OSs were affected. The actual bug involved a miscommunication between the code in the library that back-deploys fixes (`libswiftCompatibility56.a`) and the concurrency library in the OS itself. Specifically, the OS versions at the end of the ranges above introduced voucher support into the concurrency runtime in the OS (an important feature for performance). The code in `libswiftCompatibility56.a` that back-ports concurrency fixes also included the voucher support, which provides a consistent state for those OS versions and anything newer. OS versions that predate the introduction of concurrency in the OS are similarly unaffected, because the embedded `libswift_Concurrency.dylib` matches that of Swift 5.6, which includes voucher support. The OS versions in the affected range include a concurrency library in the OS that does not manage vouchers. The `libswiftCompatibility56.a` back-deployed fixes library has code that works on the same data structures but does manage vouchers, leading to crashes when (say) a job allocated by the OS version didn't set the "voucher" field, but the `libswiftCompatibility56.a` tried to free it, essentially a form of overrelease. The fix is to teach the voucher-handling code in `libswiftCompatibility56.a` to first check what version of the OS it is executing on. If it's in the affected range, all handling of vouchers is disables so it acts like the concurrency library in the OS. For both earlier OS versions and later OS versions the voucher-handler code executes unchanged. This entirely library is disabled when running on OS versions containing the Swift 5.7 concurrency library (or newer), so those don't need to pay for the extra check when dealing with vouchers. Fixes rdar://108837762, rdar://108864311, rdar://108958765.