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

tst_QPointer::threadSafety() is flaky (probably race condition)

    XMLWordPrintable

Details

    • 718d680579 (qt/qtbase/dev) 718d680579 (qt/tqtc-qtbase/dev) 376637751a (qt/tqtc-qtbase/6.2)

    Description

      Failed on CI: https://testresults.qt.io/logs/qt/qtbase/ab27bece84e52d1bdc2e1c8a972b1e349bb57154/WindowsWindows_10_21H2x86_64WindowsWindows_10_21H2x86_64MSVC2019qtci-windows-10_21H2-x86_64-51-6266a4MinimalStaticTests_Sccache/66c718be2fa32690311800b776593f97440e67f5/test_1647096609/log.txt.gz

      Valgrind runs of the below are all clean, but asan every now and then triggers:

      =================================================================
      ==235611==ERROR: LeakSanitizer: detected memory leaks
      
      Direct leak of 8 byte(s) in 1 object(s) allocated from:
          #0 0x7f9a654f4f37 in operator new(unsigned long) ../../../../gcc/libsanitizer/asan/asan_new_delete.cpp:99
          #1 0x7f9a330bc7fe in __gnu_cxx::new_allocator<QObject*>::allocate(unsigned long, void const*) /d/gcc/11/include/c++/11.2.1/ext/new_allocator.h:127
          #2 0x7f9a330bc7fe in std::allocator<QObject*>::allocate(unsigned long) /d/gcc/11/include/c++/11.2.1/bits/allocator.h:201
          #3 0x7f9a330bc7fe in std::allocator_traits<std::allocator<QObject*> >::allocate(std::allocator<QObject*>&, unsigned long) /d/gcc/11/include/c++/11.2.1/bits/alloc_traits.h:464
          #4 0x7f9a330bc7fe in std::_Vector_base<QObject*, std::allocator<QObject*> >::_M_allocate(unsigned long) /d/gcc/11/include/c++/11.2.1/bits/stl_vector.h:346
          #5 0x7f9a330bc7fe in void std::vector<QObject*, std::allocator<QObject*> >::_M_realloc_insert<QObject* const&>(__gnu_cxx::__normal_iterator<QObject**, std::vector<QObject*, std::allocator<QObject*> > >, QObject* const&) /d/gcc/11/include/c++/11.2.1/bits/vector.tcc:440
          #6 0x7f9a3308a8b8 in std::vector<QObject*, std::allocator<QObject*> >::push_back(QObject* const&) /d/gcc/11/include/c++/11.2.1/bits/stl_vector.h:1198
          #7 0x7f9a3308a8b8 in QThreadPrivate::addObjectWithPendingBindingStatusChange(QObject*) /home/marc/Qt/qtbase-build/include/QtCore/6.4.0/QtCore/private/../../../../../../qtbase/src/corelib/thread/qthread_p.h:221
          #8 0x7f9a3308a8b8 in QObject::moveToThread(QThread*) /home/marc/Qt/qtbase/src/corelib/kernel/qobject.cpp:1658
          #9 0x425939 in tst_QPointer::threadSafety() /home/marc/Qt/qtbase/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp:357
          #10 0x42c7c6 in tst_QPointer::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /home/marc/Qt/qtbase-build/tests/auto/corelib/kernel/qpointer/tst_qpointer_autogen/include/tst_qpointer.moc:118
          #11 0x42cb5e in tst_QPointer::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /home/marc/Qt/qtbase-build/tests/auto/corelib/kernel/qpointer/tst_qpointer_autogen/include/tst_qpointer.moc:104
          #12 0x7f9a32c468f5 in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const /home/marc/Qt/qtbase/src/corelib/kernel/qmetaobject.cpp:2391
          #13 0x7f9a64ebcb7a in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const /home/marc/Qt/qtbase/src/corelib/kernel/qmetaobject.h:126
          #14 0x7f9a64ebcb7a in QTest::TestMethods::invokeTestOnData(int) const /home/marc/Qt/qtbase/src/testlib/qtestcase.cpp:967
          #15 0x7f9a64ec29cd in QTest::TestMethods::invokeTest(int, char const*, QTest::WatchDog*) const /home/marc/Qt/qtbase/src/testlib/qtestcase.cpp:1211
          #16 0x7f9a64ec59f3 in QTest::TestMethods::invokeTests(QObject*) const /home/marc/Qt/qtbase/src/testlib/qtestcase.cpp:1553
          #17 0x7f9a64ec8d8c in QTest::qRun() /home/marc/Qt/qtbase/src/testlib/qtestcase.cpp:2019
          #18 0x7f9a64ed1673 in QTest::qExec(QObject*, int, char**) /home/marc/Qt/qtbase/src/testlib/qtestcase.cpp:1921
          #19 0x407544 in main /home/marc/Qt/qtbase/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp:424
          #20 0x7f9a2c8560b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b2)
      

      or

      =================================================================
      ==230405==ERROR: AddressSanitizer: requested allocation size 0x7ffffffffffffff8 (0x8000000000000ff8 after adjustments for alignment, red zones etc.) exceeds maximum supported size of 0x10000000000 (thread T0)
          #0 0x7efc6992af37 in operator new(unsigned long) ../../../../gcc/libsanitizer/asan/asan_new_delete.cpp:99
          #1 0x7efc374f27fe in __gnu_cxx::new_allocator<QObject*>::allocate(unsigned long, void const*) /d/gcc/11/include/c++/11.2.1/ext/new_allocator.h:127
          #2 0x7efc374f27fe in std::allocator<QObject*>::allocate(unsigned long) /d/gcc/11/include/c++/11.2.1/bits/allocator.h:201
          #3 0x7efc374f27fe in std::allocator_traits<std::allocator<QObject*> >::allocate(std::allocator<QObject*>&, unsigned long) /d/gcc/11/include/c++/11.2.1/bits/alloc_traits.h:464
          #4 0x7efc374f27fe in std::_Vector_base<QObject*, std::allocator<QObject*> >::_M_allocate(unsigned long) /d/gcc/11/include/c++/11.2.1/bits/stl_vector.h:346
          #5 0x7efc374f27fe in void std::vector<QObject*, std::allocator<QObject*> >::_M_realloc_insert<QObject* const&>(__gnu_cxx::__normal_iterator<QObject**, std::vector<QObject*, std::allocator<QObject*> > >, QObject* const&) /d/gcc/11/include/c++/11.2.1/bits/vector.tcc:440
          #6 0x7efc374c08b8 in std::vector<QObject*, std::allocator<QObject*> >::push_back(QObject* const&) /d/gcc/11/include/c++/11.2.1/bits/stl_vector.h:1198
          #7 0x7efc374c08b8 in QThreadPrivate::addObjectWithPendingBindingStatusChange(QObject*) /home/marc/Qt/qtbase-build/include/QtCore/6.4.0/QtCore/private/../../../../../../qtbase/src/corelib/thread/qthread_p.h:221
          #8 0x7efc374c08b8 in QObject::moveToThread(QThread*) /home/marc/Qt/qtbase/src/corelib/kernel/qobject.cpp:1658
          #9 0x425939 in tst_QPointer::threadSafety() /home/marc/Qt/qtbase/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp:357
          #10 0x42c7c6 in tst_QPointer::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /home/marc/Qt/qtbase-build/tests/auto/corelib/kernel/qpointer/tst_qpointer_autogen/include/tst_qpointer.moc:118
          #11 0x42cb5e in tst_QPointer::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /home/marc/Qt/qtbase-build/tests/auto/corelib/kernel/qpointer/tst_qpointer_autogen/include/tst_qpointer.moc:104
          #12 0x7efc3707c8f5 in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const /home/marc/Qt/qtbase/src/corelib/kernel/qmetaobject.cpp:2391
          #13 0x7efc692f2b7a in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const /home/marc/Qt/qtbase/src/corelib/kernel/qmetaobject.h:126
          #14 0x7efc692f2b7a in QTest::TestMethods::invokeTestOnData(int) const /home/marc/Qt/qtbase/src/testlib/qtestcase.cpp:967
          #15 0x7efc692f89cd in QTest::TestMethods::invokeTest(int, char const*, QTest::WatchDog*) const /home/marc/Qt/qtbase/src/testlib/qtestcase.cpp:1211
          #16 0x7efc692fb9f3 in QTest::TestMethods::invokeTests(QObject*) const /home/marc/Qt/qtbase/src/testlib/qtestcase.cpp:1553
          #17 0x7efc692fed8c in QTest::qRun() /home/marc/Qt/qtbase/src/testlib/qtestcase.cpp:2019
          #18 0x7efc69307673 in QTest::qExec(QObject*, int, char**) /home/marc/Qt/qtbase/src/testlib/qtestcase.cpp:1921
          #19 0x407544 in main /home/marc/Qt/qtbase/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp:424
          #20 0x7efc30c8c0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b2)
      

      Otherwise, after a few repetitions, I usually get various runtime errors:

      GCC 9:

      1: === Received signal at function time: 0ms, total time: 1ms, dumping stack ===
      1: GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
      1: Copyright (C) 2020 Free Software Foundation, Inc.
      1: License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
      1: This is free software: you are free to change and redistribute it.
      1: There is NO WARRANTY, to the extent permitted by law.
      1: Type "show copying" and "show warranty" for details.
      1: This GDB was configured as "x86_64-linux-gnu".
      1: Type "show configuration" for configuration details.
      1: For bug reporting instructions, please see:
      1: <http://www.gnu.org/software/gdb/bugs/>.
      1: Find the GDB manual and other documentation resources online at:
      1:     <http://www.gnu.org/software/gdb/documentation/>.
      1: 
      1: For help, type "help".
      1: Type "apropos word" to search for commands related to "word".
      1: Attaching to process 241827
      1: (gdb) === End of stack trace ===
      1: QFATAL : tst_QPointer::threadSafety() Received signal 11
      1:          Function time: 0ms Total time: 1ms
      1: FAIL!  : tst_QPointer::threadSafety() Received a fatal error.
      1: Totals: 10 passed, 1 failed, 0 skipped, 0 blacklisted, 29ms
      1: ********* Finished testing of tst_QPointer *********
      1: QObject: Cannot create children for a parent that is in a different thread.
      1: (Parent is QApplication(0x7ffc9925b060), parent's thread is QThread(0x557a49008c10), current thread is QThread(0x7ffc9925a4f0)
      1: CMake Error at tst_qpointerWrapperDebug.cmake:17 (message):
      1:   
      1:   /home/marc/Qt/qt5-build-gcc9/qtbase/tests/auto/corelib/kernel/qpointer/tst_qpointer
      1:   execution failed with exit code Subprocess aborted.
      1: 
      1: 
      1/1 Test #1: tst_qpointer .....................***Failed    0.13 sec
      

      GCC 11.3 C++17:

      1: PASS   : tst_QPointer::threadSafety()
      1: free(): invalid pointer
      1: CMake Error at tst_qpointerWrapperRelWithDebInfo.cmake:17 (message):
      1:   
      1:   /home/marc/Qt/qt5-build-c++17/qtbase/tests/auto/corelib/kernel/qpointer/tst_qpointer
      1:   execution failed with exit code Subprocess aborted.
      1: 
      1: 
      1/1 Test #1: tst_qpointer .....................***Failed    0.11 sec
      

      GCC 11.2 C++20:

      1: PASS   : tst_QPointer::castDuringDestruction()
      1: GLib (gthread-posix.c): Unexpected error from C library during 'pthread_setspecific': Invalid argument.  Aborting.
      1: CMake Error at tst_qpointerWrapperRelWithDebInfo.cmake:17 (message):
      1:   
      1:   /home/marc/Qt/qt5-build-2/qtbase/tests/auto/corelib/kernel/qpointer/tst_qpointer
      1:   execution failed with exit code Subprocess aborted.
      

      Clang + libc++:

      1: double free or corruption (out)
      1: CMake Error at tst_qpointerWrapperRelWithDebInfo.cmake:17 (message):
      1:   
      1:   /home/marc/Qt/qt5-build-clang/qtbase/tests/auto/corelib/kernel/qpointer/tst_qpointer
      1:   execution failed with exit code Subprocess aborted.
      1: 
      1: 
      1/1 Test #1: tst_qpointer .....................***Failed    0.11 sec
      

      Attachments

        Issue Links

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

          Activity

            People

              fabiankosmale Fabian Kosmale
              mmutz Marc Mutz
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There is 1 open Gerrit change