hrev47824 adds 2 changesets to branch 'master' old head: ece6f8ba5d9b1cfc56ffaa2d74bcfbd697dd0f2d new head: cab2a2ba35f6ad4f9b03584c4f2c7199a4fa451e overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=cab2a2b+%5Eece6f8b ---------------------------------------------------------------------------- 7b5a544: Debugger: Fix CID 1223239. - Rework part of report generator to add missing memory allocation error checks. cab2a2b: 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. [ Rene Gollent <rene@xxxxxxxxxxx> ] ---------------------------------------------------------------------------- 1 file changed, 40 insertions(+), 27 deletions(-) .../controllers/DebugReportGenerator.cpp | 67 ++++++++++++-------- ############################################################################ Commit: 7b5a544edb5f6fb31e60361f53ec8aef740c17e7 URL: http://cgit.haiku-os.org/haiku/commit/?id=7b5a544 Author: Rene Gollent <rene@xxxxxxxxxxx> Date: Sun Jun 22 02:06:06 2014 UTC Debugger: Fix CID 1223239. - Rework part of report generator to add missing memory allocation error checks. ---------------------------------------------------------------------------- diff --git a/src/apps/debugger/controllers/DebugReportGenerator.cpp b/src/apps/debugger/controllers/DebugReportGenerator.cpp index dd09bde..efb1517 100644 --- a/src/apps/debugger/controllers/DebugReportGenerator.cpp +++ b/src/apps/debugger/controllers/DebugReportGenerator.cpp @@ -16,6 +16,7 @@ #include "Architecture.h" #include "AreaInfo.h" +#include "AutoDeleter.h" #include "CpuState.h" #include "DebuggerInterface.h" #include "DisassembledCode.h" @@ -235,37 +236,41 @@ DebugReportGenerator::_GenerateReportHeader(BFile& _output) fTeam->Name(), fTeam->ID()); WRITE_AND_CHECK(_output, data); - SystemInfo sysInfo; - + cpu_platform platform = B_CPU_UNKNOWN; + cpu_vendor cpuVendor = B_CPU_VENDOR_UNKNOWN; + uint32 cpuModel = 0; uint32 topologyNodeCount = 0; cpu_topology_node_info* topology = NULL; get_cpu_topology_info(NULL, &topologyNodeCount); - if (topologyNodeCount != 0) - topology = new cpu_topology_node_info[topologyNodeCount]; - get_cpu_topology_info(topology, &topologyNodeCount); + if (topologyNodeCount != 0) { + topology = new(std::nothrow) cpu_topology_node_info[topologyNodeCount]; + if (topology == NULL) + return B_NO_MEMORY; - cpu_platform platform = B_CPU_UNKNOWN; - cpu_vendor cpuVendor = B_CPU_VENDOR_UNKNOWN; - uint32 cpuModel = 0; - for (uint32 i = 0; i < topologyNodeCount; i++) { - switch (topology[i].type) { - case B_TOPOLOGY_ROOT: - platform = topology[i].data.root.platform; - break; + BPrivate::ArrayDeleter<cpu_topology_node_info> deleter(topology); + get_cpu_topology_info(topology, &topologyNodeCount); - case B_TOPOLOGY_PACKAGE: - cpuVendor = topology[i].data.package.vendor; - break; + for (uint32 i = 0; i < topologyNodeCount; i++) { + switch (topology[i].type) { + case B_TOPOLOGY_ROOT: + platform = topology[i].data.root.platform; + break; - case B_TOPOLOGY_CORE: - cpuModel = topology[i].data.core.model; - break; + case B_TOPOLOGY_PACKAGE: + cpuVendor = topology[i].data.package.vendor; + break; - default: - break; + case B_TOPOLOGY_CORE: + cpuModel = topology[i].data.core.model; + break; + + default: + break; + } } } + SystemInfo sysInfo; if (fDebuggerInterface->GetSystemInfo(sysInfo) == B_OK) { const system_info &info = sysInfo.GetSystemInfo(); data.SetToFormat("CPU(s): %" B_PRId32 "x %s %s\n", @@ -289,7 +294,6 @@ DebugReportGenerator::_GenerateReportHeader(BFile& _output) WRITE_AND_CHECK(_output, data); } - delete[] topology; return B_OK; } ############################################################################ Revision: hrev47824 Commit: cab2a2ba35f6ad4f9b03584c4f2c7199a4fa451e URL: http://cgit.haiku-os.org/haiku/commit/?id=cab2a2b Author: Rene Gollent <rene@xxxxxxxxxxx> Date: Sat Sep 6 20:41:07 2014 UTC Ticket: https://dev.haiku-os.org/ticket/11204 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. ---------------------------------------------------------------------------- diff --git a/src/apps/debugger/controllers/DebugReportGenerator.cpp b/src/apps/debugger/controllers/DebugReportGenerator.cpp index efb1517..9379176 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");