Skip to content

Commit ab0e817

Browse files
authored
Merge pull request swiftlang#7694 from apple/fix_tsan_test
2 parents f1231a4 + 4808fb2 commit ab0e817

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

test/Sanitizers/tsan.swift

+15-13
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,27 @@ public func call_foobar() {
2828
// Test ThreadSanitizer execution end-to-end.
2929

3030
import Darwin
31-
var user_interactive_thread: pthread_t?
32-
var user_interactive_thread2: pthread_t?
31+
32+
var threads: [pthread_t?] = []
3333
var racey_x: Int;
3434

35-
pthread_create(&user_interactive_thread, nil, { _ in
35+
for _ in 1...5 {
36+
var t : pthread_t?
37+
pthread_create(&t, nil, { _ in
3638
print("pthread ran")
3739
racey_x = 5;
3840

3941
return nil
40-
}, nil)
41-
42-
pthread_create(&user_interactive_thread2, nil, { _ in
43-
print("pthread2 ran")
44-
racey_x = 6;
45-
46-
return nil
47-
}, nil)
42+
}, nil)
43+
threads.append(t)
44+
}
4845

49-
pthread_join(user_interactive_thread!, nil)
50-
pthread_join(user_interactive_thread2!, nil)
46+
for t in threads {
47+
if t == nil {
48+
print("nil thread")
49+
continue
50+
}
51+
pthread_join(t!, nil)
52+
}
5153

5254
// CHECK: ThreadSanitizer: data race

0 commit comments

Comments
 (0)