Skip to content

Commit 3c6f6f2

Browse files
committed
Add a test that ensures tasks get invalidated
This detects a bug unique to the oldest back-deployment targets for Swift concurrency, where Tasks were getting created with an incorrect bit pattern that made them immortal. Verifies that rdar://93087343 has been fixed.
1 parent 06061a6 commit 3c6f6f2

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// RUN: %target-run-simple-swift(-parse-as-library -Xfrontend -disable-availability-checking) | %FileCheck %s
2+
// REQUIRES: executable_test
3+
// REQUIRES: concurrency
4+
// REQUIRES: concurrency_runtime
5+
6+
// UNSUPPORTED: back_deployment_runtime
7+
8+
class C {}
9+
10+
@_silgen_name("exit")
11+
func exit(_ code : UInt32) -> Never
12+
13+
@main
14+
enum Main {
15+
static func main() async {
16+
weak var weakRef: C?
17+
do {
18+
let c = C()
19+
let t = Task.detached { return c }
20+
weakRef = c
21+
}
22+
Task.detached {
23+
try await Task.sleep(nanoseconds: 10_000_000_000)
24+
print("Fail!")
25+
exit(1)
26+
}
27+
28+
while weakRef != nil {
29+
await Task.yield()
30+
}
31+
// CHECK: Success
32+
print("Success!")
33+
}
34+
}

0 commit comments

Comments
 (0)