Author: Armin Rigo <ar...@tunes.org>
Branch: boehm-rawrefcount
Changeset: r86926:43fec2a94ecc
Date: 2016-09-07 14:22 +0200
http://bitbucket.org/pypy/pypy/changeset/43fec2a94ecc/

Log:    Test and fix

diff --git a/rpython/rlib/src/boehm-rawrefcount.c 
b/rpython/rlib/src/boehm-rawrefcount.c
--- a/rpython/rlib/src/boehm-rawrefcount.c
+++ b/rpython/rlib/src/boehm-rawrefcount.c
@@ -143,8 +143,16 @@
 
     hash_link(lnk);
 
-    int j = GC_general_register_disappearing_link((void **)&lnk->gcenc, gcobj);
-    assert(j == GC_SUCCESS);
+    if (GC_base(gcobj) == NULL) {
+        /* 'gcobj' is probably a prebuilt object - it makes no */
+        /* sense to register it then, and it crashes Boehm in */
+        /* quite obscure ways */
+    }
+    else {
+        int j = GC_general_register_disappearing_link(
+                                    (void **)&lnk->gcenc, gcobj);
+        assert(j == GC_SUCCESS);
+    }
 }
 
 static pyobj_t *hash_get_entry(gcobj_t *gcobj)
diff --git a/rpython/rlib/test/test_rawrefcount.py 
b/rpython/rlib/test/test_rawrefcount.py
--- a/rpython/rlib/test/test_rawrefcount.py
+++ b/rpython/rlib/test/test_rawrefcount.py
@@ -281,7 +281,13 @@
             assert rawrefcount.to_obj(W_Root, ob) == p
             return ob
 
+        prebuilt_p = W_Root(-42)
+        prebuilt_ob = lltype.malloc(PyObjectS, flavor='raw', zero=True,
+                                    immortal=True)
+
         def entry_point(argv):
+            rawrefcount.create_link_pypy(prebuilt_p, prebuilt_ob)
+            prebuilt_ob.c_ob_refcnt += REFCNT_FROM_PYPY
             oblist = [make_ob() for i in range(50)]
             rgc.collect()
             deadlist = []
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to