[pypy-commit] stmgc default: Test and fix.

arigo noreply at buildbot.pypy.org
Mon May 27 09:42:29 CEST 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r35:2566855246b2
Date: 2013-05-27 09:42 +0200
http://bitbucket.org/pypy/stmgc/changeset/2566855246b2/

Log:	Test and fix.

diff --git a/c3/et.c b/c3/et.c
--- a/c3/et.c
+++ b/c3/et.c
@@ -103,8 +103,15 @@
           /* we update R_prev->h_revision as a shortcut */
           /* XXX check if this really gives a worse performance than only
              doing this write occasionally based on a counter in d */
+          R = (gcptr)v;
+          if (R->h_revision == stm_local_revision)
+            {
+              /* must not update an older h_revision to go directly to
+                 the private copy at the end of a chain of protected
+                 objects! */
+              return R;
+            }
           R_prev->h_revision = v;
-          R = (gcptr)v;
           goto retry;
         }
     }
diff --git a/c3/test/test_nursery.py b/c3/test/test_nursery.py
--- a/c3/test/test_nursery.py
+++ b/c3/test/test_nursery.py
@@ -448,3 +448,19 @@
     p1 = lib.stm_pop_root()
     assert lib.rawgetlong(p1, 0) == i - 1
     assert lib.getlong(p1, 0) == i
+
+def test_dont_update_revision_to_point_to_private():
+    p1 = nalloc(HDR)
+    for i in range(50):
+        pstart = p1
+        lib.stm_push_root(pstart)
+        while True:
+            lib.stm_commit_transaction()
+            lib.stm_begin_inevitable_transaction()
+            p1 = lib.stm_write_barrier(p1)
+            if not lib.in_nursery(p1):
+                break
+        for i in range(10):
+            lib.stm_read_barrier(pstart)   # compress the chain
+        minor_collect()
+        p1 = lib.stm_pop_root()


More information about the pypy-commit mailing list