WebKit should support building with clang ThreadSanitizer (TSan) enabled. The biggest challenge here is to instrument WebKit's custom locking mechanisms so TSan is able to reason correctly about threaded memory accesses. Also need to make it easy to make it easy to build with TSan enabled like we do with ASan using `set-webkit-configuration --[no-]asan`. <rdar://problem/31615729>
Created attachment 408340 [details] WIP Patch v1 This is a WIP that implements basic TSan instrumentation for malloc::Mutex and WTF::Lock classes. It does not provide a way to enable TSan when building yet, though one can enable ASan and change ENABLE_ADDRESS_SANITIZER=YES to ENABLE_THREAD_SANITIZER=YES in Tools/asan/asan.xcconfig for Apple platforms.
Created attachment 408381 [details] WIP Patch v2 This adds build support with `make TSAN=YES` and `set-webkit-configuration --[no-]tsan`. It also fixes the build errors from "WIP Patch v1". Still not complete since we need to instrument more WTF lock classes. (I wonder if we can get away with just instrumenting the WTF::Locker class, too.) Also, I'm not sure if we should instrument malloc::Mutex or not. We may just end up tossing the bmalloc changes in this patch.
Created attachment 408391 [details] WIP Patch v3 Fix style issues and make builds.
Created attachment 408656 [details] Patch v4
Committed r267130: <https://trac.webkit.org/changeset/267130> All reviewed patches have been landed. Closing bug and clearing flags on attachment 408656 [details].