Author: Armin Rigo <[email protected]>
Branch:
Changeset: r92386:9bd6fef43680
Date: 2017-09-14 10:52 +0200
http://bitbucket.org/pypy/pypy/changeset/9bd6fef43680/
Log: Test and fix: an ll_assert() can rarely fail in debug mode in the
GC, but that's not a real problem
diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py
--- a/rpython/memory/gc/incminimark.py
+++ b/rpython/memory/gc/incminimark.py
@@ -1897,8 +1897,14 @@
if cardbyte & 1:
if interval_stop > length:
interval_stop = length
- ll_assert(cardbyte <= 1 and bytes == 0,
- "premature end of object")
+ #--- the sanity check below almost always
+ #--- passes, except in situations like
+ #--- test_writebarrier_before_copy_manually\
+ # _copy_card_bits
+ #ll_assert(cardbyte <= 1 and bytes == 0,
+ # "premature end of object")
+ ll_assert(bytes == 0, "premature end of
object")
+ cardbyte = 1
self.trace_and_drag_out_of_nursery_partial(
obj, interval_start, interval_stop)
#
diff --git a/rpython/memory/gc/minimark.py b/rpython/memory/gc/minimark.py
--- a/rpython/memory/gc/minimark.py
+++ b/rpython/memory/gc/minimark.py
@@ -1399,8 +1399,15 @@
if cardbyte & 1:
if interval_stop > length:
interval_stop = length
- ll_assert(cardbyte <= 1 and bytes == 0,
- "premature end of object")
+ #--- the sanity check below almost always
+ #--- passes, except in situations like
+ #--- test_writebarrier_before_copy_manually\
+ # _copy_card_bits
+ #ll_assert(cardbyte <= 1 and bytes == 0,
+ # "premature end of object")
+ ll_assert(bytes == 0, "premature end of
object")
+ if interval_stop <= interval_start:
+ break
self.trace_and_drag_out_of_nursery_partial(
obj, interval_start, interval_stop)
#
diff --git a/rpython/memory/test/gc_test_base.py
b/rpython/memory/test/gc_test_base.py
--- a/rpython/memory/test/gc_test_base.py
+++ b/rpython/memory/test/gc_test_base.py
@@ -995,6 +995,31 @@
self.interpret(fn, [])
+ def test_writebarrier_before_copy_manually_copy_card_bits(self):
+ S = lltype.GcStruct('S', ('x', lltype.Char))
+ TP = lltype.GcArray(lltype.Ptr(S))
+ def fn():
+ l1 = lltype.malloc(TP, 65)
+ l2 = lltype.malloc(TP, 33)
+ for i in range(65):
+ l1[i] = lltype.malloc(S)
+ l = lltype.malloc(TP, 100)
+ i = 0
+ while i < 65:
+ l[i] = l1[i]
+ i += 1
+ rgc.ll_arraycopy(l, l2, 0, 0, 33)
+ x = []
+ # force minor collect
+ t = (1, lltype.malloc(S))
+ for i in range(20):
+ x.append(t)
+ for i in range(33):
+ assert l2[i] == l[i]
+ return 0
+
+ self.interpret(fn, [])
+
def test_stringbuilder(self):
def fn():
s = StringBuilder(4)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit