[pypy-commit] pypy stm-gc: Argh, argh. Finally found the next bug.

arigo noreply at buildbot.pypy.org
Thu Apr 26 10:44:35 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r54757:22fccf3c9b5e
Date: 2012-04-25 21:57 +0200
http://bitbucket.org/pypy/pypy/changeset/22fccf3c9b5e/

Log:	Argh, argh. Finally found the next bug.

diff --git a/pypy/rpython/memory/gc/stmtls.py b/pypy/rpython/memory/gc/stmtls.py
--- a/pypy/rpython/memory/gc/stmtls.py
+++ b/pypy/rpython/memory/gc/stmtls.py
@@ -323,8 +323,10 @@
         # XXX should we also remove GCFLAG_WAS_COPIED here if it is set?
         ll_assert(hdr.tid & GCFLAG_VISITED == 0,
                   "write in main thread: unexpected GCFLAG_VISITED")
-        # remove GCFLAG_GLOBAL, and add GCFLAG_VISITED
-        hdr.tid += (GCFLAG_VISITED - GCFLAG_GLOBAL)
+        # remove GCFLAG_GLOBAL and (if it was there) GCFLAG_WAS_COPIED,
+        # and add GCFLAG_VISITED
+        hdr.tid &= ~(GCFLAG_GLOBAL | GCFLAG_WAS_COPIED)
+        hdr.tid |= GCFLAG_VISITED
         # add the object into this linked list
         hdr.version = self.mt_global_turned_local
         self.mt_global_turned_local = obj
@@ -550,7 +552,7 @@
             ll_assert(hdr.tid & GCFLAG_GLOBAL == 0,
                       "unexpected GCFLAG_GLOBAL in mt_global_turned_local")
             ll_assert(hdr.tid & GCFLAG_VISITED != 0,
-                      "missing GCFLAG_VISIBLE in mt_global_turned_local")
+                      "missing GCFLAG_VISITED in mt_global_turned_local")
             self.trace_and_drag_out_of_nursery(obj)
             obj = hdr.version
 
diff --git a/pypy/rpython/memory/gc/test/test_stmgc.py b/pypy/rpython/memory/gc/test/test_stmgc.py
--- a/pypy/rpython/memory/gc/test/test_stmgc.py
+++ b/pypy/rpython/memory/gc/test/test_stmgc.py
@@ -336,10 +336,13 @@
     def test_write_barrier_global(self):
         # check that the main thread never makes a local copy of a global obj
         t, t_adr = self.malloc(S, globl=True)
-        self.checkflags(t_adr, True, False)
+        # the following flag can be set a bit randomly on global objects
+        self.gc.header(t_adr).tid |= GCFLAG_WAS_COPIED
+        self.checkflags(t_adr, True, True)
         obj = self.gc.stm_writebarrier(t_adr)     # main thread, global:
         assert obj == t_adr                       # doesn't make a copy
         self.checkflags(obj, False, False)        # but it becomes local
+        # ^^^ but the GCFLAG_WAS_COPIED is removed in this case
 
     def test_nontransactional_mode(self):
         import random


More information about the pypy-commit mailing list