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

QFETCH() crashes with QVector2D, QVector3D and QVector4D in Release mode

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 5.9.5, 5.12.10, 5.15.2, 6.0.0
    • Testing: qtestlib
    • None
    • Linux/X11, Linux/Other display system

    Description

      For some reason that escapes me, if I write a data driven test that takes a QVector3D as input and run the test in Release mode, the QFETCH() macro crashes due to a segmentation fault while fetching the value from the _data() function.  (This also occurs with QVector2D and QVector4D).

      However, if I run the test in Debug mode it works just fine.

      Therefore I believe the cause behind the crash might be some unwanted side effects of the optimization done by the compiler in Release mode.

       

      The following minimal example works fine in Debug mode but crashes in Release mode:

      main.cpp

      #include <QVector3D>
      #include <QtTest>
      
      class MyTest : public QObject
      {
          Q_OBJECT
      
      private slots:
      
          void myTest_data();
          void myTest();
      };
      
      void MyTest::myTest_data()
      {
          QTest::addColumn<QVector3D>("vec");
          QTest::newRow("foo") << QVector3D(1, 2, 3);
      }
      
      void MyTest::myTest()
      {
          QFETCH(QVector3D, vec);
      
          QCOMPARE(vec.x(), 1);
          QCOMPARE(vec.y(), 2);
          QCOMPARE(vec.z(), 3);
      }
      
      QTEST_APPLESS_MAIN(MyTest);
      #include "main.moc"
      

       

      This is the fatal error message shown in the console:

      (gdb) QFATAL : MyTest::myTest(foo) Received signal 11
               Function time: 0ms Total time: 0ms
      FAIL!  : MyTest::myTest(foo) Received a fatal error.
         Loc: [Unknown file(0)]
      Totals: 1 passed, 1 failed, 0 skipped, 0 blacklisted, 48ms
      ********* Finished testing of MyTest *********
      === End of stack trace ===

       

      Attachments

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

        Activity

          People

            macadder Jason McDonald
            acebrianjuan Álvaro Cebrián Juan
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes