You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/NNNN-NN-NN-swift-5.10-released.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -8,21 +8,21 @@ author: [hborla]
8
8
9
9
Swift was designed to be safe by default, preventing entire categories of programming mistakes at compile time. Sources of undefined behavior in C-based languages, such as using variables before they're initialized or a use-after-free, are defined away in Swift.
10
10
11
-
A major goals of Swift's concurrency model is to define away the undefined behavior that results from accessing memory from one thread at the same time that another thread is writing to the same memory. This kind of unsafety is called a _data race_, and data races make concurrent programs exceptionally difficult to write correctly. Swift solves this problem through _data isolation_ provided by actors and tasks, which guarantees mutually exclusive access to shared mutable state. Data isolation enforcement has been under active development since the initial release of Swift concurrency.
11
+
An increasingly important source of undefined behavior is concurrent code that inadvertently accesses memory from one thread at the same time that another thread is writing to the same memory. This kind of unsafety is called a _data race_, and data races make concurrent programs exceptionally difficult to write correctly. Swift solves this problem through _data isolation_ provided by actors and tasks, which guarantees mutually exclusive access to shared mutable state. Data isolation enforcement has been under active development since 2020 when the [Swift concurrency roadmap](https://forums.swift.org/t/swift-concurrency-roadmap/41611) was posted.
12
12
13
13
**Swift 5.10 accomplishes full data isolation in the concurrency language model.** This important milestone has taken years of active development over many releases. The concurrency model was introduced in Swift 5.5 including `async`/`await`, actors, and structured concurrency. Swift 5.7 introduced `Sendable` as the fundamental concept for thread-safe types whose values can be shared across arbitrary concurrent contexts without introducing a risk of data races. And now, in Swift 5.10, full data isolation is enforced at compile time in all areas of the language when the complete concurrency checking option is enabled.
14
14
15
-
Full data isolation in Swift 5.10 sets the stage for the next major release, Swift 6. The Swift 6.0 compiler will offer a new, opt-in Swift 6 language mode that will enforce full data isolation by default, and we will embark upon the transition to eliminate data races across the Swift ecosystem.
15
+
Full data isolation in Swift 5.10 sets the stage for the next major release, Swift 6. The Swift 6.0 compiler will offer a new, opt-in Swift 6 language mode that will enforce full data isolation by default, and we will embark upon the transition to eliminate data races across all software written in Swift.
16
16
17
-
Swift 5.10 enforces full data isolation conservatively, meaning there are some false positive reports of data races. A major focus of language development for the Swift 6 release is improving the usability of strict concurrency checking by mitigating false positive concurrency errors in common code patterns that are proven to be safe.
17
+
Swift 5.10 will produce data-race warnings in some circumstances where the code could be proven safe with additional compiler analysis. A major focus of language development for the Swift 6 release is improving the usability of strict concurrency checking by mitigating false positive concurrency errors in common code patterns that are proven to be safe.
18
18
19
19
Read on to learn about full data isolation in Swift 5.10, new unsafe opt-outs for actor isolation checking, and the remaining concurrency evolution ahead of Swift 6.
20
20
21
21
## Data-race safety in Swift 5.10
22
22
23
23
### Full data isolation
24
24
25
-
Swift 5.10 rounds out the data-race safety semantics in all corners of the language, and fixes numerous bugs in `Sendable` and actor isolation checking to strengthen the guarantees of complete concurrency checking. When writing code against`-strict-concurrency=complete`, Swift 5.10 will diagnose the potential for data races at compile time except where an explicit unsafe opt-out, such as `nonisolated(unsafe)` or `@unchecked Sendable`, is used.
25
+
Swift 5.10 rounds out the data-race safety semantics in all corners of the language, and fixes numerous bugs in `Sendable` and actor isolation checking to strengthen the guarantees of complete concurrency checking. When building code with the compiler flag`-strict-concurrency=complete`, Swift 5.10 will diagnose the potential for data races at compile time except where an explicit unsafe opt-out, such as `nonisolated(unsafe)` or `@unchecked Sendable`, is used.
26
26
27
27
For example, in Swift 5.9, the following code fails an isolation assertion at runtime due to a `@MainActor`-isolated initializer being evaluated outside the actor, but it was not diagnosed under `-strict-concurrency=complete`:
28
28
@@ -96,15 +96,15 @@ Note that without correct implementation of a synchronization mechanism to achie
96
96
97
97
## Language evolution ahead of Swift 6
98
98
99
-
**The next release of Swift will be Swift 6.** The complete concurrency model in Swift 5.10 is conservative, and several Swift Evolution proposals are in active development to improve the usability of full data isolation by removing false postive datarace errors. This work includes [lifting limitations on passing non-`Sendable` values across isolation boundaries](https://github.com/apple/swift-evolution/blob/main/proposals/0414-region-based-isolation.md) when the compiler determines there is no potential for concurrent access, [more effective `Sendable` inference for functions and key-paths](https://github.com/apple/swift-evolution/blob/main/proposals/0418-inferring-sendable-for-methods.md), and more. You can find the set of proposals that will round out Swift 6 at [Swift.org/swift-evolution](https://www.swift.org/swift-evolution/#?version=6.0).
99
+
**The next release of Swift will be Swift 6.** The complete concurrency model in Swift 5.10 is overly restrictive, and several Swift Evolution proposals are in active development to improve the usability of full data isolation by removing false postive data-race errors. This work includes [lifting limitations on passing non-`Sendable` values across isolation boundaries](https://github.com/apple/swift-evolution/blob/main/proposals/0414-region-based-isolation.md) when the compiler determines there is no potential for concurrent access, [more effective `Sendable` inference for functions and key-paths](https://github.com/apple/swift-evolution/blob/main/proposals/0418-inferring-sendable-for-methods.md), and more. You can find the set of proposals that will round out Swift 6 at [Swift.org/swift-evolution](https://www.swift.org/swift-evolution/#?version=6.0).
100
100
101
101
## Next Steps
102
102
103
103
### Try out complete concurrency checking
104
104
105
105
You can help shape the transition to the Swift 6 language mode by [trying out complete concurrency checking](/documentation/concurrency/) in your project and providing feedback on your experience.
106
106
107
-
If you find any remaining soundness holes, including any corner cases where complete concurrency checking does not diagnose a data race at compile time, please [report an issue](https://github.com/apple/swift/issues/new/choose).
107
+
If you find any remaining compiler bugs where complete concurrency checking does not diagnose a data race at compile time, please [report an issue](https://github.com/apple/swift/issues/new/choose).
108
108
109
109
You can also provide feedback that helps improve the concurrency documentation, compiler error messages, and the upcoming Swift 6 migration guide. If you encounter a case where the compiler diagnoses a data-race warning that you don't understand or you're not sure how to resolve a given data-race warning, please start a [discussion thread on the Swift forums](https://forums.swift.org/tags/c/swift-users/15/concurrency) using the `concurrency` tag.
0 commit comments