From cab2a2ba35f6ad4f9b03584c4f2c7199a4fa451e Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 6 Sep 2014 16:41:07 -0400 Subject: [PATCH] Debugger: Fix #11204. - When waiting for a thread stack trace to be acquired, in some circumstances it was possible for us to not re-acquire the Team lock before moving on to parsing and writing out the information. This could potentially lead to race conditions when retrieving some of the Team's data, and ultimately crashing while writing out report data. - Add missing error check in _DumpStackFrameMemory(). - Delete team data semaphore on exit. --- .../controllers/DebugReportGenerator.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/apps/debugger/controllers/DebugReportGenerator.cpp b/src/apps/debugger/controllers/DebugReportGenerator.cpp index efb1517e44..9379176ff6 100644 --- a/src/apps/debugger/controllers/DebugReportGenerator.cpp +++ b/src/apps/debugger/controllers/DebugReportGenerator.cpp @@ -82,6 +82,9 @@ DebugReportGenerator::~DebugReportGenerator() if (fCurrentBlock != NULL) fCurrentBlock->ReleaseReference(); + + if (fTeamDataSem >= 0) + delete_sem(fTeamDataSem); } @@ -494,11 +497,12 @@ DebugReportGenerator::_DumpDebuggedThreadInfo(BFile& _output, locker.Unlock(); fTraceWaitingThread = thread; - error = acquire_sem(fTeamDataSem); - if (error == B_INTERRUPTED) - continue; - else if (error != B_OK) - return error; + do { + error = acquire_sem(fTeamDataSem); + } while (error == B_INTERRUPTED); + + if (error != B_OK) + break; locker.Lock(); } @@ -630,8 +634,10 @@ DebugReportGenerator::_DumpFunctionDisassembly(BFile& _output, do { error = acquire_sem(fTeamDataSem); } while (error == B_INTERRUPTED); + if (error != B_OK) return error; + teamLocker.Lock(); break; } @@ -687,6 +693,9 @@ DebugReportGenerator::_DumpStackFrameMemory(BFile& _output, do { error = acquire_sem(fTeamDataSem); } while (error == B_INTERRUPTED); + + if (error != B_OK) + return error; } BString data("\t\t\tFrame memory:\n");