https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63627
Bug ID: 63627 Summary: thread sanitizer does not instrument __atomic_test_and_set or __atomic_clear Product: gcc Version: 4.9.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: rogero at howzatt dot demon.co.uk CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org Created attachment 33791 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33791&action=edit EXample using __atomic_test_and_set that causes tsan positives When compiling code using atomic instrinsics with -fsanitize=thread some of the functions - in particular __atomic_test_and_set and __atomic_clear are not instrumented. Hence tsan reports false positives when spin-locking with __atomic_test_and_set/__atomic_clear but not when using __atomic_exchange_n/__atomic_store_n. (This also affects std:atomic_flag as it uses the problematic operations in its implementation.)