Skip to content

Commit 27b89cc

Browse files
author
Julian Lettner
committed
Re-enable TSan versions of async_let_fibonacci.swift test
The two TSan versions of the `test/Concurrency/Runtime/async_let_fibonacci.swift` were disabled for different reasons: [1] Swift Concurrency work broke the test and it was never re-enabled. [2] Regression in atos required test to be disabled. Re-enablement was blocked on Swift CI upgrading to an Xcode that contains the fixed version of atos. While the TSan versions of the test was not running they fell out of sync with the original test and then started failing for different (trivial) reasons once re-enabled. Please help us keep these tests running by: * Not landing work that makes them fail (and deferring the fix to a later point), if at all possible. Breaking sanitizers should be a "blocker". * Keeping them in sync with the original tests. Radar-Id: rdar://83162880 [1] rdar://76446550 (Re-enable test: Sanitizers/tsan/async_let_fibonacci.swift) [2] rdar://80274830 ([Swift CI] Sanitizer report symbolication fails due to regression in atos)
1 parent 88e0a87 commit 27b89cc

File tree

3 files changed

+14
-31
lines changed

3 files changed

+14
-31
lines changed

test/Sanitizers/symbolication.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
// REQUIRES: asan_runtime
66
// REQUIRES: VENDOR=apple
77

8-
// rdar://80274830 ([Swift CI] Sanitizer report symbolication fails because we fail to start atos, sanbox issue?)
9-
// REQUIRES: 80274830
10-
// Might be related/same issue as below
11-
128
// rdar://75365575 (Failing to start atos external symbolizer)
139
// UNSUPPORTED: OS=watchos
1410

test/Sanitizers/tsan/async_let_fibonacci.swift

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
// RUN: %target-run-simple-swift( %import-libdispatch -parse-as-library -sanitize=thread)
1+
// RUN: %target-run-simple-swift( -Xfrontend -disable-availability-checking %import-libdispatch -parse-as-library -sanitize=thread)
22

33
// REQUIRES: executable_test
44
// REQUIRES: concurrency
55
// REQUIRES: libdispatch
66
// REQUIRES: tsan_runtime
7-
// UNSUPPORTED: use_os_stdlib
87

9-
// REQUIRES: radar76446550
8+
// rdar://76038845
9+
// REQUIRES: concurrency_runtime
10+
// UNSUPPORTED: back_deployment_runtime
1011

11-
#if canImport(Darwin)
12-
import Darwin
13-
#elseif canImport(Glibc)
14-
import Glibc
15-
#endif
16-
17-
@available(SwiftStdlib 5.5, *)
1812
func fib(_ n: Int) -> Int {
1913
var first = 0
2014
var second = 1
@@ -36,12 +30,12 @@ func asyncFib(_ n: Int) async -> Int {
3630
async let second = await asyncFib(n-1)
3731

3832
// Sleep a random amount of time waiting on the result producing a result.
39-
await Task.sleep(UInt64.random(in: 0..<100) * 1000)
33+
await Task.sleep(UInt64.random(in: 0..<100) * 1_000_000)
4034

4135
let result = await first + second
4236

4337
// Sleep a random amount of time before producing a result.
44-
await Task.sleep(UInt64.random(in: 0..<100) * 1000)
38+
await Task.sleep(UInt64.random(in: 0..<100) * 1_000_000)
4539

4640
return result
4741
}

test/Sanitizers/tsan/racy_async_let_fibonacci.swift

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swiftc_driver %s -parse-as-library %import-libdispatch -target %sanitizers-target-triple -g -sanitize=thread -o %t
1+
// RUN: %target-swiftc_driver %s -Xfrontend -disable-availability-checking -parse-as-library %import-libdispatch -target %sanitizers-target-triple -g -sanitize=thread -o %t
22
// RUN: %target-codesign %t
33
// RUN: env %env-TSAN_OPTIONS="abort_on_error=0" not %target-run %t 2>&1 | %swift-demangle --simplified | %FileCheck %s
44

@@ -8,21 +8,12 @@
88
// REQUIRES: tsan_runtime
99

1010
// rdar://76038845
11-
// UNSUPPORTED: use_os_stdlib
12-
13-
// rdar://80274830 ([Swift CI] Sanitizer report symbolication fails because we fail to start atos, sanbox issue?)
14-
// REQUIRES: 80274830
15-
// Might be related/same issue as below
11+
// REQUIRES: concurrency_runtime
12+
// UNSUPPORTED: back_deployment_runtime
1613

1714
// rdar://75365575 (Failing to start atos external symbolizer)
1815
// UNSUPPORTED: OS=watchos
1916

20-
#if canImport(Darwin)
21-
import Darwin
22-
#elseif canImport(Glibc)
23-
import Glibc
24-
#endif
25-
2617
func fib(_ n: Int) -> Int {
2718
var first = 0
2819
var second = 1
@@ -36,6 +27,7 @@ func fib(_ n: Int) -> Int {
3627

3728
var racyCounter = 0
3829

30+
@available(SwiftStdlib 5.5, *)
3931
func asyncFib(_ n: Int) async -> Int {
4032
racyCounter += 1
4133
if n == 0 || n == 1 {
@@ -46,25 +38,26 @@ func asyncFib(_ n: Int) async -> Int {
4638
async let second = await asyncFib(n-1)
4739

4840
// Sleep a random amount of time waiting on the result producing a result.
49-
usleep(UInt32.random(in: 0..<100) * 1000)
41+
await Task.sleep(UInt64.random(in: 0..<100) * 1_000_000)
5042

5143
let result = await first + second
5244

5345
// Sleep a random amount of time before producing a result.
54-
usleep(UInt32.random(in: 0..<100) * 1000)
46+
await Task.sleep(UInt64.random(in: 0..<100) * 1_000_000)
5547

5648
return result
5749
}
5850

51+
@available(SwiftStdlib 5.5, *)
5952
func runFibonacci(_ n: Int) async {
6053
let result = await asyncFib(n)
6154

6255
print()
6356
print("Async fib = \(result), sequential fib = \(fib(n))")
6457
assert(result == fib(n))
65-
print("asyncFib() called around \(racyCounter) times")
6658
}
6759

60+
@available(SwiftStdlib 5.5, *)
6861
@main struct Main {
6962
static func main() async {
7063
await runFibonacci(10)

0 commit comments

Comments
 (0)