Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-123404

QtWayland uses unexported QThreadPrivate, fails UBSan build

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.11.0 FF
    • 6.6.2, 6.8.0
    • QPA: Wayland
    • None
    • Ubuntu 22.04
      gcc 11.4.0
    • Linux/Wayland
    • b40086e00 (dev)

      QtWayland fails to build with UBSan enabled under Ubuntu 22.04. With gcc the error is.

      [2125/2281] Linking CXX shared library qtbase/lib/libQt6WaylandClient.so.6.8.0
      ...
      /usr/bin/ld: qtwayland/src/client/CMakeFiles/WaylandClient.dir/qwaylandwindow.cpp.o:(.data.rel+0x8398): undefined reference to `typeinfo for QThreadPrivate'
      

      It tries to use a non-exported QThreadPrivate symbol which is mangled with UBSan enabled. These are the symbols in QtCore:

      $ nm -D libQt6Core.so | grep QThreadPrivate
      000000000419c62a B _odr_asan_gen_ZTI14QThreadPrivate@@Qt_6_PRIVATE_API
      000000000419c629 B _odr_asan_gen_ZTS14QThreadPrivate@@Qt_6_PRIVATE_API
      000000000419c628 B _odr_asan_gen_ZTV14QThreadPrivate@@Qt_6_PRIVATE_API
      ...

      With clang the shared library is linked but fails to load at runtime, not able to resolve the same symbols.

      The problem goes away when configured with "-developer-build", where QThreadPrivate is exported in QtCore.

      A similar issue was reported for QtQml in QTBUG-120216.
       
      I attached a Dockerfile to reproduce the issue. It fails both in release and debug builds. The main build steps are.

      ../configure -sanitize undefined
      cmake --build . --parallel
      

       
      Note that the current dev branch does not configure sanitizers correctly. The last commit to reproduce the issue is therefore a3f2c3037 from Mar 8, 2024. This will soon be patched here: https://codereview.qt-project.org/c/qt/qtbase/+/546797

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            tvete Paul Olav Tvete
            brugger Christian Brugger
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes