Author: Armin Rigo <[email protected]>
Branch:
Changeset: r229:5d92b334f594
Date: 2013-06-21 16:55 +0200
http://bitbucket.org/pypy/stmgc/changeset/5d92b334f594/
Log: Two tests and two fixes.
diff --git a/c4/gcpage.c b/c4/gcpage.c
--- a/c4/gcpage.c
+++ b/c4/gcpage.c
@@ -243,6 +243,8 @@
else {
assert(obj->h_tid & GCFLAG_PRIVATE_FROM_PROTECTED);
gcptr B = (gcptr)obj->h_revision;
+ gcptrlist_insert(&objects_to_trace, B);
+
if (!(B->h_tid & GCFLAG_PUBLIC)) {
/* a regular private_from_protected object with a backup copy B */
assert(B->h_tid & GCFLAG_BACKUP_COPY);
@@ -409,6 +411,21 @@
item->addr->h_tid |= GCFLAG_PUBLIC_TO_PRIVATE;
} G2L_LOOP_END;
+
+ /* It can occur that 'private_from_protected' contains an object that
+ * has not been visited at all (maybe only in inevitable
+ * transactions).
+ */
+ items = d->private_from_protected.items;
+ for (i = d->private_from_protected.size - 1; i >= 0; i--) {
+ gcptr obj = items[i];
+ assert(obj->h_tid & GCFLAG_PRIVATE_FROM_PROTECTED);
+
+ if (!(obj->h_tid & GCFLAG_VISITED)) {
+ /* forget 'obj' */
+ items[i] = items[--d->private_from_protected.size];
+ }
+ }
}
static void clean_up_lists_of_read_objects_and_fix_outdated_flags(void)
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
@@ -355,3 +355,26 @@
assert classify(p2) == "public"
perform_transaction(cb)
run_parallel(f1, f2)
+
+def test_private_from_protected_inevitable():
+ p1 = nalloc(HDR)
+ lib.stm_commit_transaction()
+ lib.stm_begin_inevitable_transaction()
+ p1b = lib.stm_write_barrier(p1)
+ assert p1b == p1
+ major_collect()
+
+def test_private_from_protected_trace_backup():
+ p1 = nalloc_refs(1)
+ p2 = nalloc(HDR)
+ lib.setptr(p1, 0, p2)
+ def cb(c):
+ if c == 0:
+ lib.setptr(p1, 0, ffi.NULL)
+ major_collect()
+ abort_and_retry()
+ lib.stm_push_root(p1)
+ perform_transaction(cb)
+ p1 = lib.stm_pop_root()
+ check_not_free(p1)
+ check_not_free(lib.getptr(p1, 0))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit