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

qtestlib deadlocks in the signal handler

    XMLWordPrintable

Details

    Description

      I got into a rare deadlock when a signal (e.g. SIGTERM) arrives to a process that uses qtestlib - if the process was interrupted in a middle of the malloc, then qtestlib deadlocks because it tries to allocate/deallocate memory from within the signal handler.

      see qtestcase.cpp:

      void FatalSignalHandler::signal(int signum)
      {
         qFatal("Received signal %d", signum);
      ...
      }
      

      here is the backtrace that I got:

      __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:97 
      97        ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: No such file or directory. 
              in ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S 
      (gdb) bt 
      #0  __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:97 
      #1  0x00007f5c68c169df in _L_lock_10501 () from /lib/x86_64-linux-gnu/libc.so.6 
      #2  0x00007f5c68c14d71 in __GI___libc_free (mem=0x7f5c68f321c0) at malloc.c:3736 
      #3  0x00007f5c69dc75e4 in QPlainTestLogger::~QPlainTestLogger (this=0x92e390, __in_chrg=<optimized out>) 
          at /home/denis/dev/qt5/qtbase/src/testlib/qplaintestlogger.cpp:323 
      #4  0x00007f5c69dc39a5 in QTest::TestLoggers::destroyLoggers () at /home/denis/dev/qt5/qtbase/src/testlib/qtestlog.cpp:131 
      #5  0x00007f5c69dc344c in QTestLog::stopLogging () at /home/denis/dev/qt5/qtbase/src/testlib/qtestlog.cpp:394 
      #6  0x00007f5c69dc3066 in QTest::messageHandler (type=QtFatalMsg, msg=0x7f5c60000948 "Received signal 2") 
          at /home/denis/dev/qt5/qtbase/src/testlib/qtestlog.cpp:278 
      #7  0x00007f5c696fa786 in qt_message_output (msgType=QtFatalMsg, context=..., buf=0x7f5c60000948 "Received signal 2") 
          at /home/denis/dev/qt5/qtbase/src/corelib/global/qlogging.cpp:708 
      #8  0x00007f5c696f8928 in qt_message(QtMsgType, const QMessageLogContext &, const char *, typedef __va_list_tag __va_list_tag *) (msgType=QtFatalMsg,  
          context=..., msg=0x7f5c69dd1c50 "Received signal %d", ap=0x7fffd3478428) at /home/denis/dev/qt5/qtbase/src/corelib/global/qlogging.cpp:131 
      #9  0x00007f5c696f8dbc in QMessageLogger::fatal (this=0x7fffd3478510, msg=0x7f5c69dd1c50 "Received signal %d") 
          at /home/denis/dev/qt5/qtbase/src/corelib/global/qlogging.cpp:334 
      #10 0x00007f5c69dbd221 in QTest::FatalSignalHandler::signal (signum=2) at /home/denis/dev/qt5/qtbase/src/testlib/qtestcase.cpp:1839 
      #11 <signal handler called> 
      #12 _int_malloc (av=0x7f5c68f321c0, bytes=16) at malloc.c:4303 
      #13 0x00007f5c68c1477d in __GI___libc_malloc (bytes=16) at malloc.c:3660 
      #14 0x00007f5c6972fe59 in QHashData::allocateNode (this=0x32ff21f0, nodeAlign=8) at /home/denis/dev/qt5/qtbase/src/corelib/tools/qhash.cpp:174 
      #15 0x00007f5c69730008 in QHashData::detach_helper (this=0x32ff21f0, node_duplicate= 
          0x411840 <QHash<unsigned int, QHashDummyValue>::duplicateNode(QHashData::Node*, void*)>,  
          node_delete=0x4117e2 <QHash<unsigned int, QHashDummyValue>::deleteNode2(QHashData::Node*)>, nodeSize=16, nodeAlign=8) 
          at /home/denis/dev/qt5/qtbase/src/corelib/tools/qhash.cpp:226 
      #16 0x0000000000411778 in QHash<unsigned int, QHashDummyValue>::detach_helper (this=0x32fe99e0) 
          at /home/denis/shadow/qt5/qtbase/include/QtCore/../../../../../dev/qt5/qtbase/src/corelib/tools/qhash.h:561 
      #17 0x0000000000411624 in QHash<unsigned int, QHashDummyValue>::detach (this=0x32fe99e0) 
          at /home/denis/shadow/qt5/qtbase/include/QtCore/../../../../../dev/qt5/qtbase/src/corelib/tools/qhash.h:291 
      #18 0x0000000000411226 in QHash<unsigned int, QHashDummyValue>::remove (this=0x32fe99e0, akey=@0x5f20b88) 
          at /home/denis/shadow/qt5/qtbase/include/QtCore/../../../../../dev/qt5/qtbase/src/corelib/tools/qhash.h:765 
      #19 0x00000000004110db in QSet<unsigned int>::remove (this=0x32fe99e0, value=@0x5f20b88) 
          at /home/denis/shadow/qt5/qtbase/include/QtCore/../../../../../dev/qt5/qtbase/src/corelib/tools/qset.h:88 
      #20 0x00000000004063ef in mpage_touch (bt=0x2d2efa0, mp=0x5f20a30) at /home/denis/dev/qt5/qtjsondb/src/3rdparty/btree/src/btree.cpp:613 
      #21 0x0000000000409e22 in btree_search_page (bt=0x2d2efa0, txn=0x2fea3e0, key=0x7fffd3478d00, cursor=0x0, searchType=SearchKey, modify=1, mpp=0x7fffd3478ca0) 
          at /home/denis/dev/qt5/qtjsondb/src/3rdparty/btree/src/btree.cpp:2019 
      #22 0x000000000040f245 in btree_txn_put (bt=0x2d2efa0, txn=0x2fea3e0, key=0x7fffd3478d00, data=0x7fffd3478d20, flags=0) 
          at /home/denis/dev/qt5/qtjsondb/src/3rdparty/btree/src/btree.cpp:3724 
      #23 0x0000000000413c5f in QBtreeTxn::put (this=0x32ffa9c0, key=0x330031c8 "1Person{a8afff71-4b1a-8335-8a72-34bc780bfe79}", keySize=45, value=0x4229bd "foobar", 
          valueSize=7) at /home/denis/dev/qt5/qtjsondb/src/3rdparty/btree/qt/qbtreetxn.cpp:92 
      #24 0x000000000041bbc1 in TestQBtree::prefixTest (this=0x7fffd3479dc0) at /home/denis/dev/qt5/qtjsondb/tests/auto/qbtree/main.cpp:1174 
      #25 0x000000000041d880 in TestQBtree::qt_static_metacall (_o=0x7fffd3479dc0, _c=QMetaObject::InvokeMetaMethod, _id=21, _a=0x7fffd3479120) at ./main.moc:102 
      #26 0x00007f5c698c21e6 in QMetaMethod::invoke (this=0x7fffd34793e0, object=0x7fffd3479dc0, connectionType=Qt::DirectConnection, returnValue=..., val0=...,  
          val1=..., val2=..., val3=..., val4=..., val5=..., val6=..., val7=..., val8=..., val9=...) 
          at /home/denis/dev/qt5/qtbase/src/corelib/kernel/qmetaobject.cpp:1642 
      #27 0x00007f5c698c15af in QMetaObject::invokeMethod (obj=0x7fffd3479dc0, member=0x9a8d20 "prefixTest", type=Qt::DirectConnection, ret=..., val0=..., val1=...,  
          val2=..., val3=..., val4=..., val5=..., val6=..., val7=..., val8=..., val9=...) at /home/denis/dev/qt5/qtbase/src/corelib/kernel/qmetaobject.cpp:1168 
      #28 0x00007f5c69dbfe31 in QMetaObject::invokeMethod (obj=0x7fffd3479dc0, member=0x9a8d20 "prefixTest", type=Qt::DirectConnection, val0=..., val1=..., val2=..., 
          val3=..., val4=..., val5=..., val6=..., val7=..., val8=..., val9=...) 
          at ../../include/QtCore/../../../../../dev/qt5/qtbase/src/corelib/kernel/qobjectdefs.h:393 
      ---Type <return> to continue, or q <return> to quit--- 
      #29 0x00007f5c69dbc139 in QTest::qInvokeTestMethodDataEntry (slot=0x9a8d20 "prefixTest") at /home/denis/dev/qt5/qtbase/src/testlib/qtestcase.cpp:1533 
      #30 0x00007f5c69dbc8f8 in QTest::qInvokeTestMethod (slotName=0x4230b0 "prefixTest()", data=0x0) at /home/denis/dev/qt5/qtbase/src/testlib/qtestcase.cpp:1650 
      #31 0x00007f5c69dbd14b in QTest::qInvokeTestMethods (testObject=0x7fffd3479dc0) at /home/denis/dev/qt5/qtbase/src/testlib/qtestcase.cpp:1804 
      #32 0x00007f5c69dbd615 in QTest::qExec (testObject=0x7fffd3479dc0, argc=1, argv=0x7fffd3479ee8) at /home/denis/dev/qt5/qtbase/src/testlib/qtestcase.cpp:2023 
      #33 0x000000000041d645 in main (argc=1, argv=0x7fffd3479ee8) at /home/denis/dev/qt5/qtjsondb/tests/auto/qbtree/main.cpp:1327 
      

      Attachments

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

        Activity

          People

            macadder Jason McDonald
            dzyubenk Denis Dzyubenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes