Skip to content

[TSan] Deflake positive TSan+libdispatch test #25669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 27 additions & 20 deletions test/Sanitizers/tsan-libdispatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,43 @@
// don't support TSan.
// UNSUPPORTED: remote_run

// rdar://51730684
// REQUIRES: disable

// Test ThreadSanitizer execution end-to-end with libdispatch.

import Dispatch

let q = DispatchQueue(label: "q", attributes: .concurrent)

let sync1 = DispatchSemaphore(value: 0)
let sync2 = DispatchSemaphore(value: 0)
let finish = DispatchSemaphore(value: 0)

let q = DispatchQueue(label: "q", attributes: .concurrent)

var racy = 1

q.async {
sync1.wait()
sync2.signal()
racy = 2
finish.signal()
}
q.async {
sync1.signal()
sync2.wait()
racy = 3
finish.signal()
func wait1_signal2() { sync1.wait(); sync2.signal() }
func signal1_wait2() { sync1.signal(); sync2.wait() }

func race() {
var racy = 1

q.async {
wait1_signal2()
racy = 2
wait1_signal2()
finish.signal()
}
q.async {
signal1_wait2()
racy = 3
signal1_wait2()
finish.signal()
}

finish.wait()
finish.wait()
}

finish.wait()
finish.wait()
// TSan %deflake as part of the test.
for _ in 1...10 {
race()
}

print("Done!")

Expand Down
1 change: 1 addition & 0 deletions test/Sanitizers/tsan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public func call_foobar() {
var threads: [pthread_t] = []
var racey_x: Int;

// TSan %deflake as part of the test.
for _ in 1...5 {
#if os(macOS) || os(iOS)
var t : pthread_t?
Expand Down