Skip to content

[tsan] Workaround uninstrumented library code #114

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
Sep 24, 2020

Conversation

benlangmuir
Copy link
Contributor

We get rare reports from TSan that there is a race between modifying the
UnitEventInfoDeque and its own destructor. This appears to be caused by
uninstrumented code in the indexstore library as well as the underlying
OS file watching library (FSEvents, inotify, etc.), which prevents TSan
from realizing that the event stream callback and the event stream
finalizer are never called concurrently. We workaround by introducing an
unnecessary mutex that we lock around the requisite calls.

rdar://69514830

We get rare reports from TSan that there is a race between modifying the
UnitEventInfoDeque and its own destructor. This appears to be caused by
uninstrumented code in the indexstore library as well as the underlying
OS file watching library (FSEvents, inotify, etc.), which prevents TSan
from realizing that the event stream callback and the event stream
finalizer are never called concurrently. We workaround by introducing an
unnecessary mutex that we lock around the requisite calls.

rdar://69514830
@benlangmuir
Copy link
Contributor Author

@swift-ci please test

@akyrtzi
Copy link
Contributor

akyrtzi commented Sep 24, 2020

I'm wondering if we should just add the mutex unconditionally anyway, instead of diverging the code based on whether sanitizer is enabled or not? What do you think, are there performance concerns?

@benlangmuir
Copy link
Contributor Author

🤷 it's a bit of overhead in every event callback. I doubt one more lock makes much difference one way or the other. My thinking was that this change is purely to workaround the lack of visibility to tsan, so it should only affect tsan builds. It also helps make it clear in the code that something weird is going on.

@benlangmuir benlangmuir merged commit b7cc40f into swiftlang:main Sep 24, 2020
@benlangmuir benlangmuir deleted the tsan-workaround branch September 24, 2020 20:02
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.

2 participants