TSAN findings in early start of simple Qt Application that comming from libdbus
already reported my findings under https://bugreports.qt.io/browse/QTBUG-108784 but the issue was closed because the findings seems to be inside DBus
Background: im testing a 400KLOC greenfield Qt project with TSAN and found that there are some warnings comming from the internal use of dbus - normaly TSAN warnings are nearly forbidden in my project and the false-positive rate is very low to none with current gcc or clang (and developers tend far too often to declare TSAN warnings falsely as false positives) - but the Qt guys wrap the dbus access in its own thread so dbus is working on its own
so i started to reduce my scenario down to a simple 5 liner Qt application and still getting TSAN warnings from dbus and reported findings to the Qt guys
i tried the current 1.12.20 and latest 1.15.x and both giving me warnings (data races and lock order inversions) see attached logs
im not directly using Dbus or the QtDBus wrapper - its only a part that gets used by QApplication
its clear to me that Qt is here just some sort of test-scenario that could be maybe used for finding threading bugs in dbus
Questions:
- is dbus TSAN tested and should be clean of warnings with Qt?
- got dbus threading tests on its own that i can try?
- any idea how to reduce the test-scenario down to a pure dbus version (never used dbus before)
im building Qt, dbus and Glib myself with TSAN support under Ubnutu 22.04
these are my build steps:
mkdir ~/qt6_dev
- build Glib with TSAN
cd ~/qt6_dev
git clone https://gitlab.gnome.org/GNOME/glib.git
cd glib
git checkout 2.72.1
cd ..
mkdir glib-build
cd glib-build
meson setup ../glib -Dbuildtype=debug -Db_sanitize=thread --prefix
~/qt6_dev/glib-install
meson compile
meson install
- build DBus with TSAN (using TSAN-Glib)
git clone https://github.com/freedesktop/dbus.git
cd dbus
git checkout dbus-1.12.20
cd ..
mkdir dbus-build
cd dbus-build
PKG_CONFIG_PATH=~/qt6_dev/glib-install/lib/x86_64-linux-gnu/pkgconfig
cmake ../dbus/cmake -DCMAKE_INSTALL_PREFIX=~/qt6_dev/dbus-install
-DCMAKE_C_FLAGS="-g -fno-omit-frame-pointer -fsanitize=thread"
-DCMAKE_MODULE_LINKER_FLAGS="-fno-omit-frame-pointer -fsanitize=thread"
cmake --build . --parallel 6
cmake --install .
- build Qt 6.4(with patch: https://codereview.qt-project.org/c/qt/qtbase/+/442720 – my first ASAN finding) with TSAN
cd ~/qt6_dev
git clone git://code.qt.io/qt/qt5.git qt6
cd qt6
perl init-repository
git checkout v6.4.0
# apply patch
cd ..
mkdir qt6-build
cd qt6-build
PKG_CONFIG_PATH=~/qt6_dev/glib-install/lib/x86_64-linux-gnu/pkgconfig ../qt6/qtbase/configure -debug -opensource -nomake examples -nomake tests -sanitize thread DBus1_ROOT=~/qt6_dev/dbus-install -prefix ~/qt6_dev/qt6-install
tests -sanitize thread -prefix ~/qt6_dev/qt6-install
cmake --build . --parallel 6
cmake --install .
- build simple example qt_tsan_tests with TSAN
int main( int argc, char* argv[] )
{
QApplication app( argc, argv );
QWidget window;
window.resize( 320, 240 );
window.show();
return app.exec();
}
- start example with
./qt_tsan_tests