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

QMultiHash::equal_range crashes when called in a const member function

    XMLWordPrintable

    Details

    • Platform/s:
      Windows
    • Commits:
      7b356d73671fb7b097399bcde9d8855264625dac (qt/qtbase/6.0) 22416ecaaf58619c716229b71cdca558fda0a861 (qt/qtbase/dev)

      Description

      This is a Qt 6 regression, it worked fine on previous versions. I tried to reproduce it on Windows with GCC 8.1.0 (provided by Qt installer).

      Compile and run the following program:

      #include <QCoreApplication>
      #include <QMultiHash>
      #include <QTimer>
      
      class C {
          QMultiHash<int, int> hash{};
      public:
          void equalRange() const {
              hash.equal_range(1);
          }
      };
      
      int main(int argc, char *argv[]) {
          QCoreApplication a(argc, argv);
      
          C().equalRange();
      
          QTimer::singleShot(0, &a, &QCoreApplication::quit);
          return a.exec();
      }
      QT -= gui
      CONFIG += c++11 console
      CONFIG -= app_bundle
      SOURCES += main.cpp

      The program crashes except when either the const specifier is removed from the function signature of equalRange(), or hash is turned into mutable.

      Backtrace:

      1 QHashPrivate::Data<QHashPrivate::MultiNode<int, int>>::find qhash.h  547  0x403aa8 
      2 QMultiHash<int, int>::equal_range                           qhash.h  1852 0x4038f4 
      3 C::equalRange                                               main.cpp 9    0x403dca 
      4 main                                                        main.cpp 18   0x4015b3  
      Thread 1 (Thread 5136.0xd7c):
      #0  0x0000000000403aa8 in QHashPrivate::Data<QHashPrivate::MultiNode<int, int> >::find (this=0x0, key=@0x6afdbc: 1) at C:/Qt/6.0.0/mingw81_64/include/QtCore/qhash.h:547
              hash = 1701952752
              bucket = 4294967364
      #1  0x00000000004038f4 in QMultiHash<int, int>::equal_range (this=0x6afe00, key=@0x6afdbc: 1) at C:/Qt/6.0.0/mingw81_64/include/QtCore/qhash.h:1852
              it = {d = 0x7740f0, bucket = 7011824}
              end = {d = 0x0, bucket = 1697151428}
      #2  0x0000000000403dca in C::equalRange (this=0x6afe00) at ..\QSettings\main.cpp:9
      No locals.
      #3  0x00000000004015b3 in main (argc=1, argv=0x773fe0) at ..\QSettings\main.cpp:18
              a = <incomplete type>

      This crash happens also in release mode (therefore it's possibly not a Q_ASSERT assertion in qhash.h:547).

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              laknoll Lars Knoll
              Reporter:
              szotsaki Szőts Ákos
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes