[Interest] TSAN findings in a simple QApplication/QMetaObject::invokeMethod example

Thiago Macieira thiago.macieira at intel.com
Thu Nov 3 17:34:08 CET 2022


On Thursday, 3 November 2022 03:21:05 PDT Dennis Luehring wrote:
> WARNING: ThreadSanitizer: data race (pid=5882)
>    Read of size 8 at 0x7b0c00002178 by thread T1:
>      #0 memcpy <null> (libtsan.so.2+0x5e806)
>      #1 QVector<QPostEvent>::realloc(int,
> QFlags<QArrayData::AllocationOption>) <null> (libQt5Core.so.5+0x2af42c)
> 
>    Previous write of size 8 at 0x7b0c00002178 by main thread:
>      #0 malloc <null> (libtsan.so.2+0x3f618)
>      #1 QArrayData::allocate(unsigned long, unsigned long, unsigned
> long, QFlags<QArrayData::AllocationOption>) <null> (libQt5Core.so.5+0xf34f1)
> #2 main
> /home/linux/dev/project/test/qt_tsan_tests_dev/qt_tsan_tests/main.cpp:9
> (qt_tsan_tests+0x402eed)

Actually this SEEMS to indicate that there's a race condition in the 
QPostEventList (which is a QVector), but I dobut that TSan is capable of 
noticing the  QMutex lock, because on Linux those are inline when uncontended.

Qt 6.4 has TSan annotations for those, but you must build Qt itself with TSan 
for them to apply to the post event list inside QtCore.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering





More information about the Interest mailing list