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

Undefined behavior in qdoc reported by clang's UBSan

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • None
    • 6.0
    • Build tools: qdoc
    • None

    Description

      Trying to build html docs for qtcore fails when I do it with LLVM 10 tooling. GCC 7.5 seems to be OK on the other hand, no clue how Clang is different (maybe just newer version so better sanitizers?)

      Error (also note some memory leaks, but this is probably a separate thing):

      [73/74] cd /home/ag/work/build/qdoc_only2/qtbase/src/corelib && /usr/local/bin/cmake -E env QT_INSTALL_DOCS="/home/ag/work/build/qdoc_only2/qtbase/./doc" QT_VERSION=6.0.0 QT_V.../corelib/doc/qtcore.qdocconf -prepare -indexdir /home/ag/work/build/qdoc_only2/./doc -no-link-errors @/home/ag/work/build/qdoc_only2/qtbase/src/corelib/.doc/Debug/includes.txt
      FAILED: qtbase/src/corelib/CMakeFiles/prepare_docs_Core 
      cd /home/ag/work/build/qdoc_only2/qtbase/src/corelib && /usr/local/bin/cmake -E env QT_INSTALL_DOCS="/home/ag/work/build/qdoc_only2/qtbase/./doc" QT_VERSION=6.0.0 QT_VER=6.0 QT_VERSION_TAG=600 BUILDDIR=/home/ag/work/build/qdoc_only2/qtbase/src/corelib /home/ag/work/build/qdoc_only2/qtbase/bin/qdoc -outputdir /home/ag/work/build/qdoc_only2/./doc/qtcore -installdir /./doc /home/ag/work/qt5_qdoc_only/qtbase/src/corelib/doc/qtcore.qdocconf -prepare -indexdir /home/ag/work/build/qdoc_only2/./doc -no-link-errors @/home/ag/work/build/qdoc_only2/qtbase/src/corelib/.doc/Debug/includes.txt
      qt.qdoc: Start qdoc for QtCore in dual process mode: prepare phase.
      /home/ag/work/qt5_qdoc_only/qttools/src/qdoc/aggregate.cpp:524:21: runtime error: downcast of address 0x616000007b80 which does not point to an object of type 'FunctionNode'
      0x616000007b80: note: object is of type 'Node'
       69 00 80 2a  d0 eb a0 01 00 00 00 00  0a 00 00 00 00 03 b8 be  f8 a2 03 00 90 61 00 00  00 00 00 00
                    ^~~~~~~~~~~~~~~~~~~~~~~
                    vptr for 'Node'
      SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/ag/work/qt5_qdoc_only/qttools/src/qdoc/aggregate.cpp:524:21 in 
      qt.qdoc: Parse source files for "QtCore"
      qt.qdoc: Source files parsed for "QtCore"
      qt.qdoc: End qdoc for QtCore in dual process mode: prepare phase.
      
      =================================================================
      ==13231==ERROR: LeakSanitizer: detected memory leaks
      
      Direct leak of 88992 byte(s) in 18 object(s) allocated from:
          #0 0x4ccf39 in realloc (/home/ag/work/build/qdoc_only2/qtbase/bin/qdoc+0x4ccf39)
          #1 0x7efd976cf5e4  (/usr/lib/x86_64-linux-gnu/libclang-10.so.1+0x11165e4)
      
      Direct leak of 13872 byte(s) in 17 object(s) allocated from:
          #0 0x4ccc1d in malloc (/home/ag/work/build/qdoc_only2/qtbase/bin/qdoc+0x4ccc1d)
          #1 0x7efd976cf60f  (/usr/lib/x86_64-linux-gnu/libclang-10.so.1+0x111660f)
      
      Direct leak of 16 byte(s) in 2 object(s) allocated from:
          #0 0x4ccf39 in realloc (/home/ag/work/build/qdoc_only2/qtbase/bin/qdoc+0x4ccf39)
          #1 0x7efd8a3d76c2  (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0x956c2)
      
      SUMMARY: AddressSanitizer: 102880 byte(s) leaked in 37 allocation(s).
      

      My setup:
      Ubuntu 18.04
      LLVM 10 (Clang 10, etc.)

      Command-line (top-level build):

      ~/work/qt5_qdoc_only/configure -opensource -confirm-license -developer-build -skip qtwebengine -skip qtpim -skip qtsystems -ccache -no-pch -nomake examples -no-headersclean -skip qt3d -sanitize address -sanitize undefined -platform linux-clang
      
      ninja -j8 html_docs_Core  # this fails
      

      Attachments

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

        Activity

          People

            docinfrastructure Documentation Infrastructure Team
            agolubev Andrei Golubev
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes