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

QVector/QArrayData instances compiled with and without QT_STRICT_ITERATORS cannot be mixed

    XMLWordPrintable

Details

    • b8fe5e1bbc7f341d03d2704a6110d6e3240589bb

    Description

      If several translation units are compiled with different -DQT_STRICT_ITERATORS options and these units try to access the same QVector instance, bad things happen. This is what valgrind reports before the crash:

      ==408059== Conditional jump or move depends on uninitialised value(s)
      ==408059==    at 0x109C6E: QArrayData::data() (qarraydata.h:64)
      ==408059==    by 0x10A6E0: QTypedArrayData<Node>::data() (qarraydata.h:209)
      ==408059==    by 0x10A47A: QTypedArrayData<Node>::begin() (qarraydata.h:212)
      ==408059==    by 0x10B32D: QVector<Node>::reallocData(int, int, QFlags<QArrayData::AllocationOption>) (qvector.h:449)
      ==408059==    by 0x10AFD8: QVector<Node>::append(Node const&) (qvector.h:539)
      ==408059==    by 0x10A9F2: suspiciousInsert(Node*) (Insert.cpp:6)
      ==408059==    by 0x10996E: Blah::Blah(int) (test_qt5_vector.cpp:21)
      ==408059==    by 0x109A01: VectorTester::testBlah() (test_qt5_vector.cpp:27)
      ==408059==    by 0x10A7CA: VectorTester::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (moc_test_qt5_vector.cpp:69)
      ==408059==    by 0x529E4D8: QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (qmetaobject.cpp:2137)
      ==408059==    by 0x529F4AD: QMetaObject::invokeMethod(QObject*, char const*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) (qmetaobject.cpp:1463)
      ==408059==    by 0x4E4352B: QTest::qInvokeTestMethod(char const*, char const*) (qobjectdefs.h:399)
      ==408059==  Uninitialised value was created by a stack allocation
      ==408059==    at 0x10B1A8: QVector<Node>::reallocData(int, int, QFlags<QArrayData::AllocationOption>) (qvector.h:431)
      

      Note that this was very hard to debug for me; for example, if the Blah::Blah was defined without that dummy integer argument, everything would work just fine. I wasn't able to reproduce this bug in the release mode, either.

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            jkt Jan Kundrát
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes