Analyzers
Talk to fellow users of Intel Analyzer tools (Intel VTune™ Profiler, Intel Advisor)
5105 Discussions

Using Windows Slim Reader Writer Locks gives false positives for data race?

Stefan_M_3
Beginner
582 Views

I have code which does the following:

ThreadA():

AcquireSRWLockExclusive(lock);

SharedVar = someVal;

ReleaseSRWLockExclusive(lock);

...

ThreadB()

AcquireSRWLockShared(lock);

var = SharedVar;

ReleaseSRWLockShared(lock);

When I run the Intel Inspector to Locate Deadlocks and Data Races it says that there is read/write data race in accessing the presimably locked SharedVar. Does the Intel Inspector properly work with slim reader / writer locks or should I just discard the issue as a false positive?

0 Kudos
4 Replies
SergeyKostrov
Valued Contributor II
582 Views
>>...When I run the Intel Inspector to Locate Deadlocks and Data Races it says that there is read/write data race... It looks right because both threads are not waiting until the shared resource is avalable. >>...should I just discard the issue as a false positive? Could you try the test case with TryAcquireSRWLockShared and TryAcquireSRWLockExclusive functions?
0 Kudos
Bernard
Valued Contributor I
582 Views

Hi Stefan,

did you first initialize slim reader/writer lock with InitializeSRWLock() function?

0 Kudos
SergeyKostrov
Valued Contributor II
582 Views
>>>>...When I run the Intel Inspector to Locate Deadlocks and Data Races it says that there is read/write data race... >> >>did you first initialize slim reader/writer lock with InitializeSRWLock() function? Intel Inspector XE would not detect the data race if something would be wrong with initialization the SRW lock. >>...should I just discard the issue as a false positive? Since ThreadA is a Writer thread ( changes value of the shared variable ) and ThreadB is a Reader thread ( reads value of the shared variable ) then a message about the data race could be considered as a warning. By design of SRW multiple threads ( readers! ) should be able to access some resource.
0 Kudos
Stefan_M_3
Beginner
582 Views

Yes. I did initialize the lock. Also i have a test which will detect if a reader thread accesses not fully written data. The test has been running for a day with no issues. 

I've also tried the sample from "Synchronization Primitives New To Windows Vista" (http://msdn.microsoft.com/en-us/magazine/cc163405.aspx). The Intel Inspector detects a race condition in that code too (in updateValue() and getValue()).

0 Kudos
Reply