From 00a4dfc8e9c23117e8e4490be5354f7d95ad73e9 Mon Sep 17 00:00:00 2001 From: Brian Demsky Date: Wed, 3 Oct 2012 01:20:48 -0700 Subject: [PATCH] random memory leak fixes and memory access fixes --- action.cc | 11 +++++++++-- model.cc | 1 + mymemory.cc | 4 ++-- nodestack.cc | 2 ++ promise.h | 1 + snapshot.cc | 2 +- threads.cc | 1 + 7 files changed, 17 insertions(+), 5 deletions(-) diff --git a/action.cc b/action.cc index 383be230..a4959aed 100644 --- a/action.cc +++ b/action.cc @@ -25,8 +25,15 @@ ModelAction::ModelAction(action_type_t type, memory_order order, void *loc, uint ModelAction::~ModelAction() { - if (cv) - delete cv; + /** We can't free the clock vector: + * The reason is as follows: + * Clock vectors are snapshotting state... when we delete model actions + * they are at the end of the node list and have invalid old clock vectors... + * They are already free at that point... + */ + + /* if (cv) + delete cv;*/ } void ModelAction::copy_from_new(ModelAction *newaction) diff --git a/model.cc b/model.cc index 4d6d7634..c0112219 100644 --- a/model.cc +++ b/model.cc @@ -1481,6 +1481,7 @@ bool ModelChecker::resolve_promises(ModelAction *write) //Make sure the promise's value matches the write's value ASSERT(promise->get_value() == write->get_value()); + delete(promise); promises->erase(promises->begin() + promise_index); resolved = true; } else diff --git a/mymemory.cc b/mymemory.cc index 2add16c3..29fd2ea9 100644 --- a/mymemory.cc +++ b/mymemory.cc @@ -157,9 +157,9 @@ bool DontFree( void * ptr ){ /** Snapshotting malloc implementation for user programs. */ void *malloc( size_t size ) { - if (mySpace) + if (mySpace) { return mspace_malloc( mySpace, size ); - else + } else return HandleEarlyAllocationRequest( size ); } diff --git a/nodestack.cc b/nodestack.cc index c364df9f..f5cb6f0e 100644 --- a/nodestack.cc +++ b/nodestack.cc @@ -418,6 +418,8 @@ void NodeStack::pop_restofstack(int numAhead) { /* Diverging from previous execution; clear out remainder of list */ unsigned int it=iter+numAhead; + for(unsigned i=it;i