Skip to content

Add experimental support for Thread Sanitizer #2076

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 5 commits into from
Apr 6, 2016
Merged

Add experimental support for Thread Sanitizer #2076

merged 5 commits into from
Apr 6, 2016

Conversation

AnnaZaks
Copy link
Contributor

@AnnaZaks AnnaZaks commented Apr 6, 2016

Thread the -sanitize=thread option through the front end and fix a bunch of races it reported.

@AnnaZaks
Copy link
Contributor Author

AnnaZaks commented Apr 6, 2016

@rjmccall, @gribozavr please, take a look!
@swift-ci Please test

@gribozavr
Copy link
Contributor

@AnnaZaks Library changes LGTM!

@@ -297,7 +297,7 @@ template <class EntryTy> class ConcurrentMap {

// Try to set the edge to the new node.
if (std::atomic_compare_exchange_strong_explicit(edge, &node, newNode,
std::memory_order_release,
std::memory_order_acq_rel,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, but I'm going to link to C++ DR 2445 in protest. :)

@rjmccall
Copy link
Contributor

rjmccall commented Apr 6, 2016

Otherwise, runtime/IRGen changes LGTM.

@gparker42
Copy link
Contributor

Can we separate the "enable tsan" changes from the "fix stuff detected by tsan" changes?


// Currently, more than one sanitizer cannot be enabled at the same time.
if (pKind != SanitizerKind::None && pKind != kind) {
SmallVector<char, 128> pb;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: SmallString?

@AnnaZaks
Copy link
Contributor Author

AnnaZaks commented Apr 6, 2016

@gparker42 They are all separate commits, which you can view individually.

@AnnaZaks
Copy link
Contributor Author

AnnaZaks commented Apr 6, 2016

@swift-ci Please test

AnnaZaks added 5 commits April 6, 2016 11:53
This patch threads the TSan option through the front end.
Make sure the memory synchronization ordering on success is strictly stronger than the memory ordering of failure. This addresses a race reported by TSan when having both Swift tests and the runtime TSanified.
This data race is benign and should not occur on the platforms we currently care about. However, do set the ordering appropriately when built with TSan to avoid reporting races from Swift code. The metadata lookup code relies on these orderings for synchronization.
It is safe to only reset the counter when the count is non-zero. We always initialize the count to zero. This race has been reported by TSan.
@AnnaZaks
Copy link
Contributor Author

AnnaZaks commented Apr 6, 2016

@swift-ci Please test

@AnnaZaks AnnaZaks merged commit 5d34f66 into master Apr 6, 2016
@slavapestov
Copy link
Contributor

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants