Commit 68f7b2b
util/qht: use striped locks under TSAN
Fixes this tsan crash, easy to reproduce with any large enough program:
$ tests/unit/test-qht
1..2
ThreadSanitizer: CHECK failed: sanitizer_deadlock_detector.h:67 "((n_all_locks_)) < (((sizeof(all_locks_with_contexts_)/sizeof((all_locks_with_contexts_)[0]))))" (0x40, 0x40) (tid=1821568)
#0 __tsan::CheckUnwind() ../../../../src/libsanitizer/tsan/tsan_rtl.cpp:353 (libtsan.so.2+0x90034)
qemu#1 __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) ../../../../src/libsanitizer/sanitizer_common/sanitizer_termination.cpp:86 (libtsan.so.2+0xca555)
qemu#2 __sanitizer::DeadlockDetectorTLS<__sanitizer::TwoLevelBitVector<1ul, __sanitizer::BasicBitVector<unsigned long> > >::addLock(unsigned long, unsigned long, unsigned int) ../../../../src/libsanitizer/sanitizer_common/sanitizer_deadlock_detector.h:67 (libtsan.so.2+0xb3616)
qemu#3 __sanitizer::DeadlockDetectorTLS<__sanitizer::TwoLevelBitVector<1ul, __sanitizer::BasicBitVector<unsigned long> > >::addLock(unsigned long, unsigned long, unsigned int) ../../../../src/libsanitizer/sanitizer_common/sanitizer_deadlock_detector.h:59 (libtsan.so.2+0xb3616)
qemu#4 __sanitizer::DeadlockDetector<__sanitizer::TwoLevelBitVector<1ul, __sanitizer::BasicBitVector<unsigned long> > >::onLockAfter(__sanitizer::DeadlockDetectorTLS<__sanitizer::TwoLevelBitVector<1ul, __sanitizer::BasicBitVector<unsigned long> > >*, unsigned long, unsigned int) ../../../../src/libsanitizer/sanitizer_common/sanitizer_deadlock_detector.h:216 (libtsan.so.2+0xb3616)
qemu#5 __sanitizer::DD::MutexAfterLock(__sanitizer::DDCallback*, __sanitizer::DDMutex*, bool, bool) ../../../../src/libsanitizer/sanitizer_common/sanitizer_deadlock_detector1.cpp:169 (libtsan.so.2+0xb3616)
qemu#6 __tsan::MutexPostLock(__tsan::ThreadState*, unsigned long, unsigned long, unsigned int, int) ../../../../src/libsanitizer/tsan/tsan_rtl_mutex.cpp:200 (libtsan.so.2+0xa3382)
qemu#7 __tsan_mutex_post_lock ../../../../src/libsanitizer/tsan/tsan_interface_ann.cpp:384 (libtsan.so.2+0x76bc3)
qemu#8 qemu_spin_lock /home/cota/src/qemu/include/qemu/thread.h:259 (test-qht+0x44a97)
qemu#9 qht_map_lock_buckets ../util/qht.c:253 (test-qht+0x44a97)
qemu#10 do_qht_iter ../util/qht.c:809 (test-qht+0x45f33)
qemu#11 qht_iter ../util/qht.c:821 (test-qht+0x45f33)
qemu#12 iter_check ../tests/unit/test-qht.c:121 (test-qht+0xe473)
qemu#13 qht_do_test ../tests/unit/test-qht.c:202 (test-qht+0xe473)
qemu#14 qht_test ../tests/unit/test-qht.c:240 (test-qht+0xe7c1)
qemu#15 test_default ../tests/unit/test-qht.c:246 (test-qht+0xe828)
qemu#16 <null> <null> (libglib-2.0.so.0+0x7daed)
qemu#17 <null> <null> (libglib-2.0.so.0+0x7d80a)
qemu#18 <null> <null> (libglib-2.0.so.0+0x7d80a)
qemu#19 g_test_run_suite <null> (libglib-2.0.so.0+0x7dfe9)
qemu#20 g_test_run <null> (libglib-2.0.so.0+0x7e055)
qemu#21 main ../tests/unit/test-qht.c:259 (test-qht+0xd2c6)
qemu#22 __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 (libc.so.6+0x29d8f)
qemu#23 __libc_start_main_impl ../csu/libc-start.c:392 (libc.so.6+0x29e3f)
qemu#24 _start <null> (test-qht+0xdb44)
Signed-off-by: Emilio Cota <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
Message-Id: <[email protected]>1 parent 047e2bd commit 68f7b2b
1 file changed
+81
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
154 | 170 | | |
155 | 171 | | |
156 | 172 | | |
| |||
160 | 176 | | |
161 | 177 | | |
162 | 178 | | |
| 179 | + | |
163 | 180 | | |
164 | 181 | | |
165 | 182 | | |
| |||
169 | 186 | | |
170 | 187 | | |
171 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
172 | 192 | | |
173 | 193 | | |
174 | 194 | | |
| |||
229 | 249 | | |
230 | 250 | | |
231 | 251 | | |
232 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
233 | 299 | | |
234 | 300 | | |
235 | | - | |
| 301 | + | |
236 | 302 | | |
237 | 303 | | |
238 | 304 | | |
| |||
250 | 316 | | |
251 | 317 | | |
252 | 318 | | |
253 | | - | |
| 319 | + | |
254 | 320 | | |
255 | 321 | | |
256 | 322 | | |
| |||
261 | 327 | | |
262 | 328 | | |
263 | 329 | | |
264 | | - | |
| 330 | + | |
265 | 331 | | |
266 | 332 | | |
267 | 333 | | |
| |||
308 | 374 | | |
309 | 375 | | |
310 | 376 | | |
311 | | - | |
| 377 | + | |
312 | 378 | | |
313 | 379 | | |
314 | 380 | | |
| |||
322 | 388 | | |
323 | 389 | | |
324 | 390 | | |
325 | | - | |
| 391 | + | |
326 | 392 | | |
327 | 393 | | |
328 | 394 | | |
329 | 395 | | |
330 | | - | |
| 396 | + | |
331 | 397 | | |
332 | 398 | | |
333 | 399 | | |
334 | 400 | | |
335 | 401 | | |
336 | | - | |
| 402 | + | |
337 | 403 | | |
338 | 404 | | |
339 | 405 | | |
| |||
345 | 411 | | |
346 | 412 | | |
347 | 413 | | |
348 | | - | |
| 414 | + | |
| 415 | + | |
349 | 416 | | |
350 | 417 | | |
351 | 418 | | |
352 | 419 | | |
353 | | - | |
| 420 | + | |
354 | 421 | | |
355 | 422 | | |
356 | 423 | | |
| |||
364 | 431 | | |
365 | 432 | | |
366 | 433 | | |
367 | | - | |
| 434 | + | |
368 | 435 | | |
369 | 436 | | |
370 | 437 | | |
| |||
390 | 457 | | |
391 | 458 | | |
392 | 459 | | |
393 | | - | |
| 460 | + | |
394 | 461 | | |
395 | 462 | | |
396 | 463 | | |
| |||
638 | 705 | | |
639 | 706 | | |
640 | 707 | | |
641 | | - | |
| 708 | + | |
642 | 709 | | |
643 | 710 | | |
644 | 711 | | |
| |||
749 | 816 | | |
750 | 817 | | |
751 | 818 | | |
752 | | - | |
| 819 | + | |
753 | 820 | | |
754 | 821 | | |
755 | 822 | | |
| |||
0 commit comments