When rolling back the undo log, the previous code restored the previous
data values but didn't actually truncate the undo log.  So, on the next
restart of the transaction, we would be growing the undo log and
performing old undos again, leading to data corruption.

Committed to trunk as obvious.
commit bb61ffd92da2fcc421420c8d5fb155e8273e0a1e
Author: torvald <torvald@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Jan 13 23:45:42 2012 +0000

    libitm: Truncate undo log after rolling back.
    
        libitm/
        * local.cc (GTM::gtm_undolog::rollback): Truncate undo log after
        rolling back.
        * containers.h (GTM::vector::set_size): New.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183173 
138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/libitm/containers.h b/libitm/containers.h
index 394b6f2..3690565 100644
--- a/libitm/containers.h
+++ b/libitm/containers.h
@@ -92,6 +92,7 @@ class vector
   size_t size() const { return m_size; }
   size_t capacity() const { return this->capacity; }
 
+  void set_size (size_t size) { m_size = size; }
   void clear() { m_size = 0; }
 
   iterator push() {
diff --git a/libitm/local.cc b/libitm/local.cc
index 5645a12..d0d96ce 100644
--- a/libitm/local.cc
+++ b/libitm/local.cc
@@ -61,6 +61,7 @@ gtm_undolog::rollback (gtm_thread* tx, size_t until_size)
           if (likely(ptr > top || (uint8_t*)ptr + len <= bot))
             __builtin_memcpy (ptr, &undolog[i], len);
        }
+      undolog.set_size(until_size);
     }
 }
 

Reply via email to