Author: Remi Meier <remi.me...@gmail.com>
Branch: 
Changeset: r1993:8d9da3988633
Date: 2016-06-29 18:21 +0200
http://bitbucket.org/pypy/stmgc/changeset/8d9da3988633/

Log:    add test that shows another bug with noconfl objs

        Since stm_validate() may remove bk_cpys from the modified_objs list,
        it can change the commit log entry that gets added to the CL. But
        currently, we create the CL entry only once, possibly do a
        validation step, but then attach the old CL entry to the CL -> wrong
        (I found doubly freed bk_cpys). Instead, recalculate the CL entry
        after validation (if it did something)

diff --git a/c8/test/test_noconfl.py b/c8/test/test_noconfl.py
--- a/c8/test/test_noconfl.py
+++ b/c8/test/test_noconfl.py
@@ -206,3 +206,35 @@
         assert get_card_value(oh, 0) == CARD_CLEAR
         assert oh not in old_objects_with_cards_set()
         stm_minor_collect()
+
+    def test_reset_obj_during_commit_process(self):
+        self.start_transaction()
+        o = stm_allocate_noconflict(16)
+        self.push_root(o)
+        self.commit_transaction()
+        assert count_commit_log_entries() == 1
+
+        self.start_transaction()
+        o = self.pop_root()
+        self.push_root(o)
+        stm_set_char(o, 'a')
+
+        self.switch(1)
+        self.start_transaction()
+        stm_set_char(o, 'b')
+        self.commit_transaction()
+
+        assert count_commit_log_entries() == 2
+        assert o in last_commit_log_entry_objs()
+
+        self.switch(0, False)
+        assert stm_get_char(o) == 'a'
+        self.commit_transaction() # validates and succeeds!
+
+        # the changes we did to our noconfl obj obviously must not appear in
+        # the commit log (since they get reverted by the validation step during
+        # commit). However, there was a bug that constructed the list of
+        # changes only once and does not account for validation to remove
+        # changes from that list.
+        assert count_commit_log_entries() == 3
+        assert o not in last_commit_log_entry_objs()
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to