[pypy-svn] r36119 - pypy/dist/pypy/rpython/memory

arigo at codespeak.net arigo at codespeak.net
Wed Jan 3 16:16:45 CET 2007


Author: arigo
Date: Wed Jan  3 16:16:43 2007
New Revision: 36119

Modified:
   pypy/dist/pypy/rpython/memory/gc.py
Log:
Fix a complete bug in x_become(): replace the old object with the new one
*before* we follow a pointer... otherwise the new object can be freed!


Modified: pypy/dist/pypy/rpython/memory/gc.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gc.py	(original)
+++ pypy/dist/pypy/rpython/memory/gc.py	Wed Jan  3 16:16:43 2007
@@ -530,7 +530,8 @@
                 item = obj + itemlength * i
                 j = 0
                 while j < len(offsets):
-                    objects.append((item + offsets[j]).address[0])
+                    pointer = item + offsets[j]
+                    objects.append(pointer.address[0])
                     j += 1
                 i += 1
 
@@ -733,13 +734,13 @@
         i = 0
         while i < len(offsets):
             pointer = obj + offsets[i]
-            objects.append(pointer.address[0])
             # -------------------------------------------------
             # begin difference from collect
             if pointer.address[0] == target_addr:
                 pointer.address[0] = source_addr
             # end difference from collect
             # -------------------------------------------------
+            objects.append(pointer.address[0])
             i += 1
         if self.is_varsize(typeid):
             offset = self.varsize_offset_to_variable_part(
@@ -753,14 +754,14 @@
                 item = obj + itemlength * i
                 j = 0
                 while j < len(offsets):
-                    objects.append((item + offsets[j]).address[0])
+                    pointer = item + offsets[j]
                     # -------------------------------------------------
                     # begin difference from collect
-                    pointer = item + offsets[j]
                     if pointer.address[0] == target_addr:
                         pointer.address[0] = source_addr
                     ## end difference from collect
                     # -------------------------------------------------
+                    objects.append(pointer.address[0])
                     j += 1
                 i += 1
 



More information about the Pypy-commit mailing list