-
-
Notifications
You must be signed in to change notification settings - Fork 146
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
ThreadSanitizer reports #52
Comments
As you note, this is a false positive as the constuctor for This might be a bug in ThreadSanitizer (it's in beta still), I'm wondering if the looping over the test causes it to see a read from the previous iteration before a write from the next? Would you consider posting this to https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual as a potential issue? Marking enkiTS functions with If you do get further reports do let me know - I'll also look into adding ThreadSanitizer to my internal testing. |
Thanks for the report by the way! |
I have been analyzing the reports some more and I've found that there is only one point of synchronization that ThreadSanitizer is complaining about. In detail, these are the changes, in case you're interested: template<uint8_t cSizeLog2, typename T> inline
bool LockLessMultiReadPipe<cSizeLog2,T>::ReaderTryReadBack( T* pOut )
{
// ...
while(true)
{
// ...
uint32_t previous = FLAG_CAN_READ;
bool bSuccess = m_Flags[ actualReadIndex ].compare_exchange_strong( previous, FLAG_INVALID, std::memory_order_acquire );
if( bSuccess )
{
break;
}
// ...
}
// ...
return true;
} and template<uint8_t cSizeLog2, typename T> inline
bool LockLessMultiReadPipe<cSizeLog2,T>::WriterTryWriteFront( const T& in )
{
// ...
m_Buffer[ actualWriteIndex ] = in;
m_Flags[ actualWriteIndex ].store( FLAG_CAN_READ, std::memory_order_release );
// ...
return true;
} |
Thanks - I'll take a look at that. |
I think this is a false positive as I use an acquire / release thread fence, but if it silences the warning it may be worth implementing even if not an issue - I'll check it doesn't adversely affect performance first. |
I'll be landing these to master after some testing, and will close this once I do - thanks for the reports! |
I've completed testing and am merging to main & closing, once again thanks for the reports! |
Just wanted to add an additional comment on ThreadSanitizer (TSAN) for future reference: It appears the issue of TSAN not recognising thread fences is known - see about 3/4 the way down this thread about TBB and TASN. |
I have been testing latest master (4f9941b).
ThreadSanitizer, enabled under XCode 11.0, is reporting some data races when running unmodified samples.
I am reporting the output of one Data race report for
ParallelSum
as an example.This is reporting that reading
subTask.pTask->m_RangeToRun
is a data raceWhen declaring
ParallelSumTaskSet m_ParallelSumTaskSet;
insidestruct ParallelReductionSumTaskSet
will initialize
ParallelSumTaskSet::m_RangeToRun
in the constructor:I am not expert on the field, but it looks like a potential false positive, because
TryRunTask
is executed only afterAddTaskSetToPipe
.I try to keep our software clean from all sanitizer reports, so that I can catch real bugs ;)
For this reason if this or other reports look safe, I suggest to add annotations that disable TSAN where appropriate (using
no_sanitize("thread")
).Does it make sense for me to report all data races found by the TSAN output?
Oh, and thanks for your excellent work on the library :)
The text was updated successfully, but these errors were encountered: