From: Brian Demsky Date: Wed, 3 Oct 2012 08:20:48 +0000 (-0700) Subject: random memory leak fixes and memory access fixes X-Git-Tag: pldi2013~115 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker.git;a=commitdiff_plain;h=00a4dfc8e9c23117e8e4490be5354f7d95ad73e9 random memory leak fixes and memory access fixes --- diff --git a/action.cc b/action.cc index 383be23..a4959ae 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 4d6d763..c011221 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 2add16c..29fd2ea 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 c364df9..f5cb6f0 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