google / gwpsan

GWPSan: Sampling-Based Sanitizer Framework
Apache License 2.0
307 stars 9 forks source link

tsan: Fix stack data-race detection #12

Closed copybara-service[bot] closed 5 months ago

copybara-service[bot] commented 5 months ago

tsan: Fix stack data-race detection

In TSan we exclude sampling stack variables of the current thread, because it would dominate the samples and reduce effective data race detection probability.

The comment above the stack variable check states that if the other thread samples the access (sets up a watchpoint), we should still detect the data race (because the watchpoint triggers in the thread that owns the stack variable). However, the check was still filtering a triggered watchpoint because all events are filtered with IsInteresting() and we did not distinguish between sampled accesses and those that triggered a watchpoint.

Fix it by only filtering stack variables if no watchpoint is set up, i.e. we know the IsInteresting() call is a sampled access.