Bug 216318 - WebKit should support building with clang ThreadSanitizer enabled
Summary: WebKit should support building with clang ThreadSanitizer enabled
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
URL:
Keywords: InRadar
Depends on:
Blocks: 216746
  Show dependency treegraph
 
Reported: 2020-09-09 10:34 PDT by David Kilzer (:ddkilzer)
Modified: 2021-01-28 15:00 PST (History)
16 users (show)

See Also:


Attachments
WIP Patch v1 (8.68 KB, patch)
2020-09-09 10:38 PDT, David Kilzer (:ddkilzer)
ddkilzer: review-
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
WIP Patch v2 (28.99 KB, patch)
2020-09-09 16:21 PDT, David Kilzer (:ddkilzer)
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
WIP Patch v3 (29.80 KB, patch)
2020-09-09 18:35 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff
Patch v4 (24.31 KB, patch)
2020-09-13 11:18 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2020-09-09 10:34:33 PDT
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>
Comment 1 David Kilzer (:ddkilzer) 2020-09-09 10:38:41 PDT
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.
Comment 2 David Kilzer (:ddkilzer) 2020-09-09 16:21:14 PDT
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.
Comment 3 David Kilzer (:ddkilzer) 2020-09-09 18:35:52 PDT
Created attachment 408391 [details]
WIP Patch v3

Fix style issues and make builds.
Comment 4 David Kilzer (:ddkilzer) 2020-09-13 11:18:43 PDT
Created attachment 408656 [details]
Patch v4
Comment 5 EWS 2020-09-15 19:53:41 PDT
Committed r267130: <https://trac.webkit.org/changeset/267130>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 408656 [details].