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

Undefined behavior in moc

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.15.2
    • Fix Version/s: 6.0.1, 6.1.0 Alpha
    • Component/s: Build tools: moc
    • Labels:
      None
    • Environment:
      Ubuntu 20.04 LTS 64 bit
      clang 10.0.0
    • Commits:
      df8fbcf382b086e96082a8eb3622c60273e94c4d (qt/qtbase/dev) faaf8f5c0a73a27a159f00027ebeba5d486be6a9 (qt/qtbase/6.0) 0b4adb5b63221d423e4bdd6d07b3460d3d5cc6fe (qt/qtbase/5.15)

      Description

      1. Apply 323361 to qtbase.
        With this, undefined behavior causes a crash instead of just being logged.
      2. Configure Qt with:
        -platform linux-clang -sanitize undefined
        

        For the sake of completeness, all switches I used are:

        -platform linux-clang -opensource -confirm-license -nomake examples -nomake tests -prefix $PWD/qtbase -release -static -sanitize fuzzer-no-link -sanitize undefined -no-gc-binaries
        
      3. Build Qt.
        Building will fail with a signed integer overflow:
        make[3]: Entering directory '/home/qtrob/dev/clang-10.0.0/qt-5.15.2-base_svg-fuzz-ubsan/qtbase/src/network'
        /home/qtrob/dev/clang-10.0.0/qt-5.15.2-base_svg-fuzz-ubsan/qtbase/bin/moc -DQT_NO_LINKED_LIST -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_USING_NAMESPACE -DQT_NO_FOREACH -DQT_USE_SYSTEM_PROXIES -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_BUILD_NETWORK_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_DEPRECATED_WARNINGS_SINCE=0x060000 -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_CORE_LIB --include /home/qtrob/dev/clang-10.0.0/qt-5.15.2-base_svg-fuzz-ubsan/qtbase/src/network/.moc/moc_predefs.h -I/home/qtrob/dev/src/qt-5.15.2-base_svg/qtbase/mkspecs/linux-clang -I/home/qtrob/dev/src/qt-5.15.2-base_svg/qtbase/src/network -I/home/qtrob/dev/src/qt-5.15.2-base_svg/qtbase/src/network/kernel -I/home/qtrob/dev/clang-10.0.0/qt-5.15.2-base_svg-fuzz-ubsan/qtbase/include -I/home/qtrob/dev/clang-10.0.0/qt-5.15.2-base_svg-fuzz-ubsan/qtbase/include/QtNetwork -I/home/qtrob/dev/clang-10.0.0/qt-5.15.2-base_svg-fuzz-ubsan/qtbase/include/QtNetwork/5.15.2 -I/home/qtrob/dev/clang-10.0.0/qt-5.15.2-base_svg-fuzz-ubsan/qtbase/include/QtNetwork/5.15.2/QtNetwork -I/home/qtrob/dev/clang-10.0.0/qt-5.15.2-base_svg-fuzz-ubsan/qtbase/include/QtCore/5.15.2 -I/home/qtrob/dev/clang-10.0.0/qt-5.15.2-base_svg-fuzz-ubsan/qtbase/include/QtCore/5.15.2/QtCore -I/home/qtrob/dev/clang-10.0.0/qt-5.15.2-base_svg-fuzz-ubsan/qtbase/include/QtCore -I. -I/usr/include/c++/9 -I/usr/include/x86_64-linux-gnu/c++/9 -I/usr/include/c++/9/backward -I/usr/lib/llvm-10/lib/clang/10.0.0/include -I/usr/include/x86_64-linux-gnu -I/usr/include /home/qtrob/dev/src/qt-5.15.2-base_svg/qtbase/src/network/access/qspdyprotocolhandler_p.h -o .moc/moc_qspdyprotocolhandler_p.cpp
        /home/qtrob/dev/src/qt-5.15.2-base_svg/qtbase/src/tools/moc/preprocessor.cpp:889:22: runtime error: signed integer overflow: 2147483647 * 2 cannot be represented in type 'int'
        SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/qtrob/dev/src/qt-5.15.2-base_svg/qtbase/src/tools/moc/preprocessor.cpp:889:22 in 
        make[3]: *** [Makefile:5751: .moc/moc_qspdyprotocolhandler_p.cpp] Error 1
        

        Attachments

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

          Activity

            People

            Assignee:
            fabiankosmale Fabian Kosmale
            Reporter:
            rlohning Robert Löhning
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes