Commit c69de51
committed
Eliminate ThreadSanitizer warnings in JIT T2C mode
This fixes data races detected by ThreadSanitizer when running with JIT
compilation enabled:
1. Fix quit flag data race:
- Change 'volatile bool quit' to '_Atomic bool quit'
- Use atomic_store() for writes and atomic_load() for reads
- Initialize with atomic_init()
2. Fix TOCTOU race in wait_queue access:
- Move list_empty() check inside mutex-protected critical section
- Hold mutex during entire queue manipulation
These changes ensure thread-safe communication between the main thread
and T2C compilation thread, eliminating all TSAN warning while improving
CPU efficiency by avoiding busy-waiting.1 parent 5d9599e commit c69de51
3 files changed
+36
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1132 | 1132 | | |
1133 | 1133 | | |
1134 | 1134 | | |
| 1135 | + | |
1135 | 1136 | | |
1136 | 1137 | | |
1137 | 1138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
220 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
221 | 233 | | |
| 234 | + | |
222 | 235 | | |
223 | 236 | | |
224 | 237 | | |
| |||
727 | 740 | | |
728 | 741 | | |
729 | 742 | | |
730 | | - | |
| 743 | + | |
731 | 744 | | |
732 | 745 | | |
733 | 746 | | |
734 | 747 | | |
| 748 | + | |
735 | 749 | | |
736 | 750 | | |
737 | 751 | | |
| |||
836 | 850 | | |
837 | 851 | | |
838 | 852 | | |
839 | | - | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
840 | 857 | | |
841 | 858 | | |
842 | 859 | | |
| 860 | + | |
843 | 861 | | |
844 | 862 | | |
845 | 863 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
197 | 198 | | |
198 | 199 | | |
199 | 200 | | |
200 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
201 | 204 | | |
202 | 205 | | |
203 | 206 | | |
| |||
0 commit comments