Commit ecd5c35
Fix TSAN data races in InspectorFlags and InspectorPackagerConnection
Summary:
Fix two ThreadSanitizer data races caught by the messenger_demo integration test under dev-tsan mode.
**InspectorFlags**: `loadFlagsAndAssertUnchanged()` reads and writes `cachedValues_` without synchronization. The main thread calls it via `getIsProfilingBuild()` while the JS thread calls it via `getNetworkInspectionEnabled()`, racing on the shared `optional<Values>`. Add a `std::mutex` to protect `cachedValues_` access. The lock is taken after computing `newValues` from feature flags, so flag reads stay outside the critical section.
**InspectorPackagerConnection**: `Impl::connect()` is called from the main thread but accesses `webSocket_` which is also read by `didFailWithError()` on the inspector thread. Dispatch the body of `connect()` to the inspector thread via `scheduleCallback()`, matching the pattern `reconnect()` already uses.
Changelog: [Internal]
Differential Revision: D1018096161 parent 5f69a91 commit ecd5c35
3 files changed
Lines changed: 23 additions & 9 deletions
File tree
- packages/react-native/ReactCommon/jsinspector-modern
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
| |||
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
| 89 | + | |
| 90 | + | |
87 | 91 | | |
88 | 92 | | |
89 | 93 | | |
| |||
93 | 97 | | |
94 | 98 | | |
95 | 99 | | |
96 | | - | |
97 | 100 | | |
98 | 101 | | |
99 | 102 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
85 | | - | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| |||
Lines changed: 15 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
337 | 346 | | |
338 | 347 | | |
339 | 348 | | |
| |||
0 commit comments