random memory leak fixes and memory access fixes
authorBrian Demsky <bdemsky@uci.edu>
Wed, 3 Oct 2012 08:20:48 +0000 (01:20 -0700)
committerBrian Demsky <bdemsky@uci.edu>
Wed, 3 Oct 2012 08:20:48 +0000 (01:20 -0700)
action.cc
model.cc
mymemory.cc
nodestack.cc
promise.h
snapshot.cc
threads.cc

index 383be23..a4959ae 100644 (file)
--- 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)
index 4d6d763..c011221 100644 (file)
--- 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
index 2add16c..29fd2ea 100644 (file)
@@ -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 );
 }
 
index c364df9..f5cb6f0 100644 (file)
@@ -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<node_list.size();i++)
+               delete node_list[i];
        node_list.resize(it);
 }
 
index 83198b2..11719fc 100644 (file)
--- a/promise.h
+++ b/promise.h
@@ -21,6 +21,7 @@ class Promise {
        int increment_threads() { return ++numthreads; }
        uint64_t get_value() const { return value; }
 
+       SNAPSHOTALLOC
  private:
        const uint64_t value;
        const modelclock_t expiration;
index dadb759..6d59e7b 100644 (file)
@@ -139,7 +139,7 @@ void initSnapShotLibrary(unsigned int numbackingpages,
                unsigned int numheappages, VoidFuncPtr entryPoint) {
        /* Setup a stack for our signal handler....  */
        stack_t ss;
-       ss.ss_sp = model_malloc(SIGSTACKSIZE);
+       ss.ss_sp = PageAlignAddressUpward(model_malloc(SIGSTACKSIZE+PAGESIZE-1));
        ss.ss_size = SIGSTACKSIZE;
        ss.ss_flags = 0;
        sigaltstack(&ss, NULL);
index 39f0495..836bf2c 100644 (file)
@@ -119,6 +119,7 @@ void Thread::complete()
  * @param a The parameter to pass to this function.
  */
 Thread::Thread(thrd_t *t, void (*func)(void *), void *a) :
+       creation(NULL),
        pending(NULL),
        start_routine(func),
        arg(a),