From 3c4e543b3c76759bd76479f67e5f80e8632ee276 Mon Sep 17 00:00:00 2001 From: Clement Date: Tue, 2 Oct 2018 09:47:27 -0700 Subject: [PATCH] Better deadlock crash --- interface/src/Application.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 2cbe996e3c..b36221ca82 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -410,6 +410,10 @@ public: }); } + void setMainThreadID(Qt::HANDLE threadID) { + _mainThreadID = threadID; + } + static void updateHeartbeat() { auto now = usecTimestampNow(); auto elapsed = now - _heartbeat; @@ -417,7 +421,9 @@ public: _heartbeat = now; } - static void deadlockDetectionCrash() { + void deadlockDetectionCrash() { + setCrashAnnotation("_mod_faulting_tid", std::to_string((uint64_t)_mainThreadID)); + setCrashAnnotation("deadlock", "1"); uint32_t* crashTrigger = nullptr; *crashTrigger = 0xDEAD10CC; } @@ -504,6 +510,8 @@ public: static ThreadSafeMovingAverage _movingAverage; bool _quit { false }; + + Qt::HANDLE _mainThreadID = nullptr; }; std::atomic DeadlockWatchdogThread::_paused; @@ -1092,7 +1100,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo } // Set up a watchdog thread to intentionally crash the application on deadlocks if (!DISABLE_WATCHDOG) { - (new DeadlockWatchdogThread())->start(); + auto deadlockWatchdogThread = new DeadlockWatchdogThread(); + deadlockWatchdogThread->setMainThreadID(QThread::currentThreadId()); + deadlockWatchdogThread->start(); } // Set File Logger Session UUID