From 518a8ab0fe67965555973788e3eea643882cb80c Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 15 Jul 2010 10:36:18 +0200 Subject: fix for looping crash log on data abort When a thread panics, calling resume allows the thread to proceed to the exit handler and shut down. When a thread takes an exception, calling resume continues from the same point so the exception happens again. To avoid this, we add crashed thread ids to a list. If we see the same thread crash again, we terminate the process without trying to fetch the call stack a second time. Reviewed-by: Jason Barron --- tools/runonphone/trksignalhandler.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tools/runonphone/trksignalhandler.cpp b/tools/runonphone/trksignalhandler.cpp index b6d446f..898692a 100644 --- a/tools/runonphone/trksignalhandler.cpp +++ b/tools/runonphone/trksignalhandler.cpp @@ -71,8 +71,10 @@ private: QFile crashlogtextfile; QFile crashstackfile; QList queuedCrashes; + QList dyingThreads; QString crashlogPath; bool crashlog; + bool terminateNeeded; }; void TrkSignalHandler::copyingStarted() @@ -201,15 +203,23 @@ void TrkSignalHandler::stopped(uint pc, uint pid, uint tid, const QString& reaso cs.crashPC = pc; cs.crashReason = reason; - d->queuedCrashes.append(cs); - - if (d->queuedCrashes.count() == 1) { - d->err << "Fetching registers and stack..." << endl; - emit getRegistersAndCallStack(pid, tid); + if (d->dyingThreads.contains(tid)) { + if(d->queuedCrashes.isEmpty()) + emit terminate(); + else + d->terminateNeeded = true; + } else { + d->queuedCrashes.append(cs); + d->dyingThreads.append(tid); + + if (d->queuedCrashes.count() == 1) { + d->err << "Fetching registers and stack..." << endl; + emit getRegistersAndCallStack(pid, tid); + } } } else - emit resume(pid, tid); + emit terminate(); } void TrkSignalHandler::registersAndCallStackReadComplete(const QList& registers, const QByteArray& stack) @@ -307,6 +317,8 @@ void TrkSignalHandler::registersAndCallStackReadComplete(const QList& regi d->err << "Fetching registers and stack..." << endl; emit getRegistersAndCallStack(cs.pid, cs.tid); } + else if (d->terminateNeeded) + emit terminate(); } @@ -333,7 +345,8 @@ TrkSignalHandlerPrivate::TrkSignalHandlerPrivate() : out(stdout), err(stderr), loglevel(0), - lastpercent(0) + lastpercent(0), + terminateNeeded(false) { } -- cgit v0.12