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 383be230aaea3f4b505266688fde98ce7a6a8640..a4959aed90bf868c0ca542ea67c2e8ba75204b42 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 4d6d7634bf26c58eb83e2070b99df902c05b41ba..c01122191d0e712750b382f87b9c0edbfecf9aa2 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 2add16c33868ef00d7cca763e5d87187d95baa8f..29fd2ea94a1ebaa57767a3542dd1d78fe454d25d 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 c364df9f7613178e2453d05bd667f64f44ed4fde..f5cb6f0e2f4bcf1b8ee350485825f2afec0d28fb 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 83198b27758ffffa4f783986f2f1125e7c654c48..11719fc3b2c291307f61e9480205265436ca7b48 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 dadb75956c1f4254c3ecc84d519cd7431a8910af..6d59e7be6f68cae62c018639d2deeaeb4c36d0c7 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 39f049541d69184cc012bcd042f2400208863a3a..836bf2c72a7056923c4d3c09865076bb5fe9caef 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),