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

Memory leaks in qobjectrace destroyRace test

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • None
    • 6.1
    • Core: Other
    • None
    • Linux/X11

    Description

      I see memory leaks with LeakSanitizer when running qobjectrace (this is the test executable, for some reason without "tst_" in front). This is visible on Ubuntu 18, but is a cross-platform issue likely.
      The amount of separate leaks varies per run (e.g. 1 leak or 2 leaks) which, given the nature of the test, seems like an issue because of a race condition somewhere. The leak information suggests that we leak some objects allocated inside "QObject::connect()".

      Log (ran twice to show the issue with variable number of leaks):

      ag@ag:~/work/build/qt5/qtbase$ ./tests/auto/other/qobjectrace/qobjectrace destroyRace
      ********* Start testing of tst_QObjectRace *********
      Config: Using QtTest library 6.1.0, Qt 6.1.0 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 7.5.0), ubuntu 18.04
      PASS   : tst_QObjectRace::initTestCase()
      PASS   : tst_QObjectRace::destroyRace()
      PASS   : tst_QObjectRace::cleanupTestCase()
      Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 21061ms
      ********* Finished testing of tst_QObjectRace *********
      
      =================================================================
      ==6147==ERROR: LeakSanitizer: detected memory leaks
      
      Direct leak of 32 byte(s) in 1 object(s) allocated from:
          #0 0x7fa584b70448 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0448)
          #1 0x55acd26feb70 in QMetaObject::Connection QObject::connect<void (MyObject::*)(), void (MyObject::*)()>(QtPrivate::FunctionPointer<void (MyObject::*)()>::Object const*, void (MyObject::*)(), QtPrivate::FunctionPointer<void (MyObject::*)()>::Object const*, void (MyObject::*)(), Qt::ConnectionType) include/QtCore/../../../../../qt5/qtbase/src/corelib/kernel/qobject.h:239
          #2 0x55acd26ecdc1 in tst_QObjectRace::destroyRace() /home/ag/work/qt5/qtbase/tests/auto/other/qobjectrace/tst_qobjectrace.cpp:280
          #3 0x55acd26eedfb in tst_QObjectRace::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) tests/auto/other/qobjectrace/qobjectrace_autogen/include/tst_qobjectrace.moc:81
          #4 0x7fa5837ae30b in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const /home/ag/work/qt5/qtbase/src/corelib/kernel/qmetaobject.cpp:2340
          #5 0x7fa5847bd7f0 in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (/home/ag/work/build/qt5/qtbase/lib/libQt6Test.so.6+0x837f0)
          #6 0x7fa5847a9d1d in QTest::TestMethods::invokeTestOnData(int) const /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:934
          #7 0x7fa5847abefe in QTest::TestMethods::invokeTest(int, char const*, QTest::WatchDog*) const /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:1163
          #8 0x7fa5847af4c7 in QTest::TestMethods::invokeTests(QObject*) const /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:1506
          #9 0x7fa5847b0ba6 in QTest::qRun() /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:1933
          #10 0x7fa5847afe3a in QTest::qExec(QObject*, int, char**) /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:1841
          #11 0x55acd26eeca8 in main /home/ag/work/qt5/qtbase/tests/auto/other/qobjectrace/tst_qobjectrace.cpp:565
          #12 0x7fa5829e2bf6 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
      
      Direct leak of 24 byte(s) in 1 object(s) allocated from:
          #0 0x7fa584b70448 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0448)
          #1 0x55acd26fee69 in std::enable_if<QtPrivate::FunctionPointer<Functor>::ArgumentCount==(-1), QMetaObject::Connection>::type QObject::connect<void (MyObject::*)(), Functor>(QtPrivate::FunctionPointer<void (MyObject::*)()>::Object const*, void (MyObject::*)(), QObject const*, Functor, Qt::ConnectionType) include/QtCore/../../../../../qt5/qtbase/src/corelib/kernel/qobject.h:317
          #2 0x55acd26ecf9c in tst_QObjectRace::destroyRace() /home/ag/work/qt5/qtbase/tests/auto/other/qobjectrace/tst_qobjectrace.cpp:282
          #3 0x55acd26eedfb in tst_QObjectRace::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) tests/auto/other/qobjectrace/qobjectrace_autogen/include/tst_qobjectrace.moc:81
          #4 0x7fa5837ae30b in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const /home/ag/work/qt5/qtbase/src/corelib/kernel/qmetaobject.cpp:2340
          #5 0x7fa5847bd7f0 in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (/home/ag/work/build/qt5/qtbase/lib/libQt6Test.so.6+0x837f0)
          #6 0x7fa5847a9d1d in QTest::TestMethods::invokeTestOnData(int) const /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:934
          #7 0x7fa5847abefe in QTest::TestMethods::invokeTest(int, char const*, QTest::WatchDog*) const /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:1163
          #8 0x7fa5847af4c7 in QTest::TestMethods::invokeTests(QObject*) const /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:1506
          #9 0x7fa5847b0ba6 in QTest::qRun() /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:1933
          #10 0x7fa5847afe3a in QTest::qExec(QObject*, int, char**) /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:1841
          #11 0x55acd26eeca8 in main /home/ag/work/qt5/qtbase/tests/auto/other/qobjectrace/tst_qobjectrace.cpp:565
          #12 0x7fa5829e2bf6 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
      
      SUMMARY: AddressSanitizer: 56 byte(s) leaked in 2 allocation(s).
      
      
      ag@ag:~/work/build/qt5/qtbase$ ./tests/auto/other/qobjectrace/qobjectrace destroyRace
      ********* Start testing of tst_QObjectRace *********
      Config: Using QtTest library 6.1.0, Qt 6.1.0 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 7.5.0), ubuntu 18.04
      PASS   : tst_QObjectRace::initTestCase()
      PASS   : tst_QObjectRace::destroyRace()
      PASS   : tst_QObjectRace::cleanupTestCase()
      Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 20946ms
      ********* Finished testing of tst_QObjectRace *********
      
      =================================================================
      ==6176==ERROR: LeakSanitizer: detected memory leaks
      
      Direct leak of 48 byte(s) in 2 object(s) allocated from:
          #0 0x7fa4e7792448 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0448)
          #1 0x561ec0fb1e69 in std::enable_if<QtPrivate::FunctionPointer<Functor>::ArgumentCount==(-1), QMetaObject::Connection>::type QObject::connect<void (MyObject::*)(), Functor>(QtPrivate::FunctionPointer<void (MyObject::*)()>::Object const*, void (MyObject::*)(), QObject const*, Functor, Qt::ConnectionType) include/QtCore/../../../../../qt5/qtbase/src/corelib/kernel/qobject.h:317
          #2 0x561ec0f9ff9c in tst_QObjectRace::destroyRace() /home/ag/work/qt5/qtbase/tests/auto/other/qobjectrace/tst_qobjectrace.cpp:282
          #3 0x561ec0fa1dfb in tst_QObjectRace::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) tests/auto/other/qobjectrace/qobjectrace_autogen/include/tst_qobjectrace.moc:81
          #4 0x7fa4e63d030b in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const /home/ag/work/qt5/qtbase/src/corelib/kernel/qmetaobject.cpp:2340
          #5 0x7fa4e73df7f0 in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (/home/ag/work/build/qt5/qtbase/lib/libQt6Test.so.6+0x837f0)
          #6 0x7fa4e73cbd1d in QTest::TestMethods::invokeTestOnData(int) const /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:934
          #7 0x7fa4e73cdefe in QTest::TestMethods::invokeTest(int, char const*, QTest::WatchDog*) const /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:1163
          #8 0x7fa4e73d14c7 in QTest::TestMethods::invokeTests(QObject*) const /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:1506
          #9 0x7fa4e73d2ba6 in QTest::qRun() /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:1933
          #10 0x7fa4e73d1e3a in QTest::qExec(QObject*, int, char**) /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:1841
          #11 0x561ec0fa1ca8 in main /home/ag/work/qt5/qtbase/tests/auto/other/qobjectrace/tst_qobjectrace.cpp:565
          #12 0x7fa4e5604bf6 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
      
      SUMMARY: AddressSanitizer: 48 byte(s) leaked in 2 allocation(s).
      

      I guess any cmake build with address sanitizer turned on should show these issues.

      Attachments

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

        Activity

          People

            cnn Qt Core & Network
            agolubev Andrei Golubev
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes