Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Stefan_M_3
Beginner
58 Views

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

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
58 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?
Bernard
Black Belt
58 Views

Hi Stefan,

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

SergeyKostrov
Valued Contributor II
58 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.
Stefan_M_3
Beginner
58 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()).

Reply