Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r933:0126f6216527
Date: 2014-03-03 11:01 +0100
http://bitbucket.org/pypy/stmgc/changeset/0126f6216527/

Log:    Fix (from demo/demo_random): needs to check more directly if we use
        'overflow_number' or not. Otherwise a badly placed major collection
        can run minor_collect(commit=false) in this transaction.

diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -331,9 +331,6 @@
     assert(STM_PSEGMENT->safe_point == SP_RUNNING);
     assert(STM_PSEGMENT->running_pthread == pthread_self());
 
-    bool has_any_overflow_object =
-        (STM_PSEGMENT->objects_pointing_to_nursery != NULL);
-
     minor_collection(/*commit=*/ true);
 
     s_mutex_lock();
@@ -363,10 +360,11 @@
     push_modified_to_other_segments();
 
     /* update 'overflow_number' if needed */
-    if (has_any_overflow_object) {
+    if (STM_PSEGMENT->overflow_number_has_been_used) {
         highest_overflow_number += GCFLAG_OVERFLOW_NUMBER_bit0;
         assert(highest_overflow_number != 0);   /* XXX else, overflow! */
         STM_PSEGMENT->overflow_number = highest_overflow_number;
+        STM_PSEGMENT->overflow_number_has_been_used = false;
     }
 
     /* send what is hopefully the correct signals */
diff --git a/c7/stm/core.h b/c7/stm/core.h
--- a/c7/stm/core.h
+++ b/c7/stm/core.h
@@ -97,6 +97,7 @@
        transaction is done, but only if we actually overflowed any
        object; otherwise, no object has got this number. */
     uint32_t overflow_number;
+    bool overflow_number_has_been_used;
 
     /* The marker stored in the global 'write_locks' array to mean
        "this segment has modified this old object". */
diff --git a/c7/stm/nursery.c b/c7/stm/nursery.c
--- a/c7/stm/nursery.c
+++ b/c7/stm/nursery.c
@@ -248,6 +248,11 @@
     dprintf(("minor_collection commit=%d\n", (int)commit));
 
     STM_PSEGMENT->minor_collect_will_commit_now = commit;
+    if (!commit) {
+        /* 'STM_PSEGMENT->overflow_number' is used now by this collection,
+           in the sense that it's copied to the overflow objects */
+        STM_PSEGMENT->overflow_number_has_been_used = true;
+    }
 
     /* We need this to track the large overflow objects for a future
        commit.  We don't need it if we're committing now. */
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to