Commit d341a65
authored
Avoid a potential race condition and use-after-free when calling
If a test creates an unstructured, non-detached task that continues
running after the test has finished and eventually calls
`Test.cancel()`, then it may be able to see a reference to the test's
(or test case's) task after it has been destroyed by the Swift runtime.
This PR ensures that the infrastructure under `Test.cancel()` clears its
reference to the test's task before returning. This then minimizes the
risk of observing the task after it has been destroyed.
Further work at the Swift runtime level may be required to completely
eliminate this race condition, but this change makes it sufficiently
narrow that any example I can come up with is contrived.
### Checklist:
- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.Test.cancel(). (#1395)1 parent 56a6b79 commit d341a65
1 file changed
+11
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
91 | | - | |
| 92 | + | |
92 | 93 | | |
93 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
94 | 103 | | |
95 | 104 | | |
96 | 105 | | |
| |||
0 commit comments