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

QList<T>::count(const T&) triggers undefined behavior sanitizer when list is empty

    XMLWordPrintable

    Details

    • Commits:
      6855b80eae (qt/tqtc-qtbase/6.3)

      Description

      This minimal example triggers the UndefinedBehaviorSanitizer:

      QList<int> list;
      list.count(2)

      Output from UndefinedBehaviorSanitizer (clang 12.0.0)

      /.../include/QtCore/qlist.h:198:52: runtime error: reference binding to null pointer of type 'const int'
          #0 0x5ac304 in QList<int>::const_iterator::operator*() const /.../include/QtCore/qlist.h:198:45
          #1 0x5797e8 in long long QList<int>::count<int>(int const&) const /.../include/QtCore/qlist.h:524:38
      
      SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /.../include/QtCore/qlist.h:198:52 i

      We discovered this in our test suite, when trying to migrate to Qt 6.2.

        Attachments

        For Gerrit Dashboard: QTBUG-98770
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            thiago Thiago Macieira
            Reporter:
            frichter Florian Richter
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes