I encountered a strange problem with my Qt-based multi-thread application. After several days running, the application will freeze without any response.

After freeze occurred, I can confirm that several threads, including the main thread, are in futex_wait_queue_me status. When I attach to that application to investigate thread status by GDB, the backtrace of those threads
shows that they all stopped at the following function with the same argument i.e. futex=0x45a2f8b8 <main_arena>.

__lll_lock_wait_private (futex=0x45a2f8b8 <main_arena>)

I know that on Linux, using non-asynchronous-safe functions within signal handlers is one of possible reasons for this status, i.e. several threads wait for the same mutex, (I can confirm from backtrace that they all stopped at malloc()/free() related function calls), but after I confirmed my Qt application, I can not find implementations related to Linux signal handlers. (but I am not sure whether Qt core library is using Linux signal handlers in its signal/slot mechanism.)

I am sorry that I can not provide source code for this question because it is a huge project. Would you like tell me some possible reasons for this phenomenon, or some advises on how to debug it?

Thanks in advance.

I can provide backtrace, but sorry I have to delete some sensible information.

Backtrace of sub thread:
Qt Code:
  1. #0 in __lll_lock_wait_private (futex=0x4ad078b8 <main_arena>)
  2. #1 in __GI___libc_malloc (bytes=32) at malloc.c:2918
  3.  
  4. #11 in SystemEventImp::event(QEvent*) ()
  5. #12 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
  6. #13 in QApplication::notify(QObject*, QEvent*) ()
  7. #14 in QCoreApplication::notifyInternal(QObject*, QEvent*) ()
  8. #15 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
  9. #16 in QCoreApplication::sendPostedEvents (receiver=0x0, event_type=0) at kernel/qcoreapplication.cpp:1329
  10. #17 in QWindowSystemInterface::sendWindowSystemEvents (flags=...) at kernel/qwindowsysteminterface.cpp:560
  11. #18 in QUnixEventDispatcherQPA::processEvents (this=0x8079958, flags=...) at eventdispatchers/qunixeventdispatcher.cpp:70
  12. #19 in QEventLoop::processEvents (this=0xbfffef50, flags=...) at kernel/qeventloop.cpp:136
  13. #20 in QEventLoop::exec (this=0xbfffef50, flags=...) at kernel/qeventloop.cpp:212
  14. #21 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1120
  15. #22 in QGuiApplication::exec () at kernel/qguiapplication.cpp:1220
  16. #23 in QApplication::exec () at kernel/qapplication.cpp:2689
  17. #24 in main(argc=2, argv=0xbffff294)
To copy to clipboard, switch view to plain text mode 

Backtrace of main thread:
Qt Code:
  1. #0 in __lll_lock_wait_private (futex=0x4ad078b8 <main_arena>) at ../ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.c:32
  2. #1 in __GI___libc_malloc (bytes=8) at malloc.c:2918
  3. ... ...
  4. #15 in QGraphicsView::paintEvent(QPaintEvent*) ()
  5. #16 in QWidget::event(QEvent*) ()
  6. #17 in QFrame::event(QEvent*) ()
  7. #18 in QGraphicsView::viewportEvent(QEvent*) ()
  8. #19 in Platform::Drawing::GraphicsView::viewportEvent(QEvent*) ()
  9. #20 in QAbstractScrollAreaFilter::eventFilter(QObject*, QEvent*) ()
  10. #21 in QCoreApplicationPrivate::cancel_handler(QObject*, QEvent*) ()
  11. #22 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
  12. #23 in QApplication::notify(QObject*, QEvent*) ()
  13. #24 in QCoreApplication::notifyInternal(QObject*, QEvent*) ()
  14. #25 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) [clone .part.175] ()
  15. #26 in QWidgetBackingStore::sync() ()
  16. #27 in QWidgetPrivate::syncBackingStore() ()
  17. #28 in QWidget::event(QEvent*) ()
  18. #29 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
  19. #30 in QApplication::notify(QObject*, QEvent*) ()
  20. #31 in QCoreApplication::notifyInternal(QObject*, QEvent*) ()
  21. #32 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
  22. #33 in QCoreApplication::sendPostedEvents (receiver=0x809ea50, event_type=77)
  23. #34 in QGraphicsViewPrivate::dispatchPendingUpdateRequests (this=0x80e4418)
  24. #35 in QGraphicsScenePrivate::_q_processDirtyItems (this=0x80de238) at graphicsview/qgraphicsscene.cpp:508
  25. #36 in QGraphicsScene::qt_static_metacall (_o=0x80d1a80, _c=QMetaObject::InvokeMetaMethod, _id=15, _a=0x865e238)
  26. #37 in QMetaCallEvent::placeMetaCall (this=0x898d020, object=0x80d1a80)
  27. #38 in QObject::event (this=0x80d1a80, e=0x898d020) at kernel/qobject.cpp:1070
  28. #39 in QGraphicsScene::event (this=0x80d1a80, event=0x898d020) at graphicsview/qgraphicsscene.cpp:3478
  29. #40 in QApplicationPrivate::notify_helper (this=0x8077ba0, receiver=0x80d1a80, e=0x898d020) at kernel/qapplication.cpp:3457
  30. #41 in QApplication::notify (this=0x8077970, receiver=0x80d1a80, e=0x898d020) at kernel/qapplication.cpp:2878
  31. #42 in QCoreApplication::notifyInternal (this=0x8077970, receiver=0x80d1a80, event=0x898d020) at kernel/qcoreapplication.cpp:867
  32. #43 in QCoreApplication::sendEvent (receiver=0x80d1a80, event=0x898d020) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:232
  33. #44 in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x8073318) at kernel/qcoreapplication.cpp:1471
  34. #45 in QCoreApplication::sendPostedEvents (receiver=0x0, event_type=0) at kernel/qcoreapplication.cpp:1329
  35. #46 in QWindowSystemInterface::sendWindowSystemEvents (flags=...) at kernel/qwindowsysteminterface.cpp:560
  36. #47 in QUnixEventDispatcherQPA::processEvents (this=0x8079958, flags=...) at eventdispatchers/qunixeventdispatcher.cpp:70
  37. #48 in QEventLoop::processEvents (this=0xbfffef50, flags=...) at kernel/qeventloop.cpp:136
  38. #49 in QEventLoop::exec (this=0xbfffef50, flags=...) at kernel/qeventloop.cpp:212
  39. #50 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1120
  40. #51 in QGuiApplication::exec () at kernel/qguiapplication.cpp:1220
  41. #52 in QApplication::exec () at kernel/qapplication.cpp:2689
  42. #53 in main(argc=2, argv=0xbffff294)
To copy to clipboard, switch view to plain text mode