Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r212:2e72ea3bca12
Date: 2013-06-20 17:22 +0200
http://bitbucket.org/pypy/stmgc/changeset/2e72ea3bca12/

Log:    The next test is complete I think, but leads to unexpected aborts

diff --git a/c4/gcpage.c b/c4/gcpage.c
--- a/c4/gcpage.c
+++ b/c4/gcpage.c
@@ -582,7 +582,7 @@
     countdown_next_major_coll = next;
 }
 
-void stm_major_collect(void)
+static void major_collect(void)
 {
     stmgcpage_acquire_global_lock();
     fprintf(stderr, ",-----\n| running major collection...\n");
@@ -628,7 +628,7 @@
        threads will also acquire the RW lock in exclusive mode, but won't
        do anything. */
     if (countdown_next_major_coll == 0)
-        stm_major_collect();
+        major_collect();
 
     stm_stop_single_thread();
 
diff --git a/c4/nursery.c b/c4/nursery.c
--- a/c4/nursery.c
+++ b/c4/nursery.c
@@ -385,6 +385,14 @@
         !g2l_any_entry(&d->young_objects_outside_nursery)*/ ) {
         /* there is no young object */
         assert(gcptrlist_size(&d->public_with_young_copy) == 0);
+        assert(gcptrlist_size(&d->list_of_read_objects) >=
+               d->num_read_objects_known_old);
+        assert(gcptrlist_size(&d->private_from_protected) >=
+               d->num_private_from_protected_known_old);
+        d->num_read_objects_known_old =
+            gcptrlist_size(&d->list_of_read_objects);
+        d->num_private_from_protected_known_old =
+            gcptrlist_size(&d->private_from_protected);
         return 0;
     }
     else {
diff --git a/c4/test/test_et.py b/c4/test/test_et.py
--- a/c4/test/test_et.py
+++ b/c4/test/test_et.py
@@ -407,8 +407,10 @@
         assert classify(follow_revision(p)) == "stub"
         assert p1.h_revision & 1
         r.set(2)
+        r.wait(3)     # wait until the other thread really started
     def f2(r):
         r.wait(2)
+        r.set(3)
         p2 = lib.stm_read_barrier(p)    # steals
         assert classify(p2) == "public"
         q2 = lib.getptr(p2, 0)
diff --git a/c4/test/test_gcpage.py b/c4/test/test_gcpage.py
--- a/c4/test/test_gcpage.py
+++ b/c4/test/test_gcpage.py
@@ -313,3 +313,38 @@
     assert p1b == p1
     check_not_free(follow_revision(p1))
     assert follow_revision(p1).h_tid & GCFLAG_BACKUP_COPY
+
+def test_backup_stolen():
+    py.test.skip("unexpected abort")
+    p = palloc(HDR)
+    def f1(r):
+        p1 = lib.stm_write_barrier(p)   # private copy
+        lib.stm_commit_transaction()
+        lib.stm_begin_inevitable_transaction()
+        assert classify(p) == "public"
+        assert classify(p1) == "protected"
+        assert classify(follow_revision(p)) == "stub"
+        assert p1.h_revision & 1
+        def cb(c):
+            assert c == 0
+            p1b = lib.stm_write_barrier(p1)
+            assert p1b == p1
+            assert classify(p1) == "private_from_protected"
+            assert classify(follow_revision(p1)) == "backup"
+            r.wait_while_in_parallel()
+            check_not_free(p1)
+            assert classify(p1) == "private_from_protected"
+            assert classify(follow_revision(p1)) == "public"  # has been stolen
+        perform_transaction(cb)
+    def f2(r):
+        def cb(c):
+            assert c == 0
+            r.enter_in_parallel()
+            p2 = lib.stm_read_barrier(p)    # steals
+            assert classify(p2) == "public"
+            r.leave_in_parallel()
+            major_collect()
+            check_not_free(p2)
+            assert classify(p2) == "public"
+        perform_transaction(cb)
+    run_parallel(f1, f2)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to