Open lindsayad opened 2 years ago
Hi Alex,
Currently there is no existing option in tsan that can help to detect this. TSan could randomize scheduling of threads to provoke more bugs. It was discussed somewhere before, but can't find any references now. But this is not implemented in the current tsan version.
Understood. Thanks for the quick reply!
This is based off of https://github.com/libMesh/libmesh/pull/3146#issuecomment-1024526256. This simple function reports as tsan clean when run with multiple threads:
even though there is a read-write race for
payload
ifacquire
happens beforerelease
. If you swap the first two lines of the function, you get race detection. If I make the threads wait a while, with one waiting a bit longer than the other before proceeding to the racey section of the program, then I again get race detectionI was wondering if there is a way to help tsan with "possible" race detection in the initial program? I've looked through the run-time and compile-time options and didn't really see anything that fit, but I could easily be missing something. I understand that conceptually the race is contingent on
acquire
happening beforerelease
, and that conceptually there is no race ifrelease
happens beforeacquire
. Maybe it is impossible to bake in some logic that assumes no sychronizes-with relationship will actually occur at run-time, which I would think would then be able of catching the possible race. I am still not 100% comfortable with terminology so this could be a stupid post ... in which case please close.