-
Notifications
You must be signed in to change notification settings - Fork 459
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
Check Jolt with TSAN in CI #1278
Conversation
This commit adds a new GitHub Actions workflow that checks Jolt with ThreadSanitizer under Ubuntu & Clang. The workflow is triggered on every push to the repository. This commit also replaces usage of atomic_thread_fences in Reference.h and JobSystem.h with regular atomic ops when building under TSAN, as it does not support fences and unlikely ever will do so.
Thanks! I'll make some cosmetic changes to it before merging. I'm surprised that it needed this few changes, when I tried it last it triggered so many false positives that there was no way I was going to fix them all. |
* Moving tsan_check.yml into the main build.yml * Added a separate ReleaseTSAN target (similar to e.g. ReleaseUBSAN) * Including Core.h is not needed (if it hasn't been included JPH_NAMESPACE_BEGIN will not have been defined) * Style changes
I'm a bit at a loss why the TSAN test passed at first. If I use your original change and locally run what was in
compile and run:
then I get the same errors as we're seeing now. |
Ah, I think I understand, you can see in the build log:
while
means they're not actually passed to cmake. Edit: Put them all on the same line and now |
Jolt/Core/Semaphore.h
Outdated
inline int GetValue() const | ||
{ | ||
#if defined(JPH_TSAN_ENABLED) && !defined(JPH_PLATFORM_WINDOWS) | ||
// TSAN complains that we're reading mCount without locking. We don't care if we read a stale value. Inserting a lock to keep TSAN happy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it be better to use an atomic_int in relaxed mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning to change it to __attribute__((no_sanitize("thread")))
, but yes that's a better idea.
…rformanceTest later again) Turn on compiler optimizations Implemented @SirLynix's suggestion
@romasandu-gaijin Thanks for getting the ball rolling on this! I'll re-add the PerformanceTest later (if I can get it to work). |
The PerformanceTests have been added. They actually found one valid race condition and I had to disable a bunch of false positives. See #1285. |
@jrouwe oh snap. How come newlines don't actually work? O_o |
Also @jrouwe, a general observation of mine is that TSAN never actually emits false positives. Every single warning is an actual violation of the C++ standard memory model in my experience, it's just that sometimes it is REALLY hard to understand why exactly something is a data race. I might try and take a look at all the places you've suppressed and try to convince you that they are actual races and not false positives =) |
Yes, please go ahead! I looked at them very carefully and I think that they are not.
|
Added a new CI workflow for checking Jolt with TSAN. I think it works.
Also patched Reference.h and JobSystem.h to not use atomic_thread_fences under TSAN.
Tackles #1275