Commit 4e81f0a
Add ThreadSanitizer CI jobs (Linux + macOS) (#148)
Add ThreadSanitizer (TSan) support for detecting data races at runtime.
[Created by Copilot on behalf of @bghgary]
## Changes
- **CMakeLists.txt**: New `ENABLE_THREAD_SANITIZER` option with
`-fsanitize=thread`. Includes a mutual exclusion check with
`ENABLE_SANITIZERS` since TSan and ASan cannot be combined.
- **.github/workflows/build-linux.yml**: New `enable-thread-sanitizer`
input, passed as `ENABLE_THREAD_SANITIZER` to CMake. Wires
`TSAN_OPTIONS` with suppression file and sets `JSC_useConcurrentGC=0`
for the Run Tests step (see below).
- **.github/workflows/build-macos.yml**: New `enable-thread-sanitizer`
input; wires `TSAN_OPTIONS`.
- **.github/workflows/ci.yml**: New `Ubuntu_ThreadSanitizer_clang` and
`macOS_Xcode164_ThreadSanitizer` jobs.
- **.github/tsan_suppressions.txt**: Suppresses JSC-internal data races
on Ubuntu (`called_from_lib:libjavascriptcoregtk`). These are
allocator-level races in JSC's JIT worker threads that we cannot fix.
## Linux TSan: Concurrent GC Workaround
JSC on Linux uses `pthread_kill(tid, SIGUSR1)` + `sem_wait` in
`WTF::Thread::suspend()` to stop mutator threads at GC safepoints.
TSan's signal interception defers SIGUSR1 delivery indefinitely when the
target is inside instrumented code; the handler never runs and the
Collector Thread's `sem_wait` deadlocks. macOS JSC uses Mach
`thread_suspend()` (no Unix signals) and is unaffected.
Setting `JSC_useConcurrentGC=0` on the Linux TSan job removes the
dedicated Collector Thread; GC runs on the mutator without cross-thread
signals. Reproduced locally in WSL Ubuntu: default configuration hung
9/20 runs; with `JSC_useConcurrentGC=0`, 0/30 runs hung.
## Dependency Updates
- **arcana.cpp**: Points to upstream `microsoft/arcana.cpp` (includes
#61 — TSan-safe test hook callback mutex).
- **UrlLib**: Points to upstream `BabylonJS/UrlLib` at `d251ad44`
(includes BabylonJS/UrlLib#27 — Apple WebSocket `@synchronized` fixes).
## Platform Support
TSan is supported on Linux and macOS with Clang/GCC. MSVC does not
support TSan and Clang targeting Windows does not have a TSan runtime
library.
## CI Impact
The TSan jobs run in parallel with other jobs and do not increase
overall pipeline time.
## Status
- macOS TSan: passes clean
- Ubuntu TSan: JSC-internal races suppressed via
`called_from_lib:libjavascriptcoregtk`; concurrent GC disabled to avoid
TSan/signal deadlock
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 49e2980 commit 4e81f0a
5 files changed
Lines changed: 72 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| |||
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| 43 | + | |
39 | 44 | | |
40 | 45 | | |
41 | 46 | | |
| |||
45 | 50 | | |
46 | 51 | | |
47 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| |||
28 | 32 | | |
29 | 33 | | |
30 | 34 | | |
31 | | - | |
| 35 | + | |
| 36 | + | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
37 | 42 | | |
38 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
86 | 94 | | |
87 | 95 | | |
88 | 96 | | |
| |||
114 | 122 | | |
115 | 123 | | |
116 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
88 | 93 | | |
89 | 94 | | |
90 | 95 | | |
| |||
111 | 116 | | |
112 | 117 | | |
113 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
114 | 128 | | |
115 | 129 | | |
116 | 130 | | |
| |||
0 commit comments