[Box Backup-commit] COMMIT r1358 - box/chris/merge/lib/common
boxbackup-dev at fluffy.co.uk
boxbackup-dev at fluffy.co.uk
Sun Mar 4 23:06:18 GMT 2007
Author: chris
Date: 2007-03-04 23:06:18 +0000 (Sun, 04 Mar 2007)
New Revision: 1358
Modified:
box/chris/merge/lib/common/DebugMemLeakFinder.cpp
Log:
Watch out for our leak tracking data being destroyed and don't crash when
subsequent objects are destroyed. (refs #3, merges [1341])
Modified: box/chris/merge/lib/common/DebugMemLeakFinder.cpp
===================================================================
--- box/chris/merge/lib/common/DebugMemLeakFinder.cpp 2007-03-04 23:04:02 UTC (rev 1357)
+++ box/chris/merge/lib/common/DebugMemLeakFinder.cpp 2007-03-04 23:06:18 UTC (rev 1358)
@@ -49,6 +49,17 @@
{
static std::map<void *, MallocBlockInfo> sMallocBlocks;
static std::map<void *, ObjectInfo> sObjectBlocks;
+ static bool sTrackingDataDestroyed = false;
+
+ static class DestructionWatchdog
+ {
+ public:
+ ~DestructionWatchdog()
+ {
+ sTrackingDataDestroyed = true;
+ }
+ }
+ sWatchdog;
static bool sTrackMallocInSection = false;
static std::set<void *> sSectionMallocBlocks;
@@ -225,6 +236,8 @@
{
InternalAllocGuard guard;
+ ASSERT(!sTrackingDataDestroyed);
+
memleakfinder_notaleak_insert_pre();
if(memleakfinder_global_enable && memleakfinder_initialised)
{
@@ -258,6 +271,8 @@
InternalAllocGuard guard;
ASSERT(memleakfinder_initialised);
+ ASSERT(!sTrackingDataDestroyed);
+
sTrackMallocInSection = true;
sSectionMallocBlocks.clear();
sTrackObjectsInSection = true;
@@ -270,6 +285,7 @@
InternalAllocGuard guard;
ASSERT(memleakfinder_initialised);
+ ASSERT(!sTrackingDataDestroyed);
std::set<void *>::iterator s(sSectionMallocBlocks.begin());
for(; s != sSectionMallocBlocks.end(); ++s)
@@ -295,6 +311,7 @@
InternalAllocGuard guard;
ASSERT(memleakfinder_initialised);
+ ASSERT(!sTrackingDataDestroyed);
int n = 0;
@@ -316,6 +333,8 @@
{
InternalAllocGuard guard;
+ ASSERT(!sTrackingDataDestroyed);
+
for(std::map<void *, MallocBlockInfo>::const_iterator i(sMallocBlocks.begin()); i != sMallocBlocks.end(); ++i)
{
if(is_leak(i->first)) ::fprintf(file, "Block 0x%p size %d allocated at %s:%d\n", i->first, i->second.size, i->second.file, i->second.line);
@@ -388,6 +407,7 @@
if(!memleakfinder_global_enable) return;
if(!memleakfinder_initialised) return;
+ ASSERT(!sTrackingDataDestroyed);
if(block != 0)
{
@@ -411,6 +431,7 @@
if(!memleakfinder_global_enable) return;
if(!memleakfinder_initialised) return;
+ if(sTrackingDataDestroyed) return;
std::map<void *, ObjectInfo>::iterator i(sObjectBlocks.find(block));
if(i != sObjectBlocks.end())
More information about the Boxbackup-commit
mailing list