[pypy-commit] stmgc default: Missing one potential root inside the major gc tracing.

arigo noreply at buildbot.pypy.org
Wed Mar 5 07:44:26 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r954:5e4ec1af0e0c
Date: 2014-03-05 07:44 +0100
http://bitbucket.org/pypy/stmgc/changeset/5e4ec1af0e0c/

Log:	Missing one potential root inside the major gc tracing.

diff --git a/c7/stm/gcpage.c b/c7/stm/gcpage.c
--- a/c7/stm/gcpage.c
+++ b/c7/stm/gcpage.c
@@ -405,6 +405,14 @@
             tl = tl->next;
         } while (tl != stm_all_thread_locals);
     }
+
+    long i;
+    for (i = 0; i < NB_SEGMENTS; i++) {
+        if (get_priv_segment(i)->transaction_state != TS_NONE)
+            mark_visit_object(
+                get_priv_segment(i)->threadlocal_at_start_of_transaction,
+                get_segment_base(i));
+    }
 }
 
 static void mark_visit_from_modified_objects(void)
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -14,6 +14,7 @@
 
 typedef struct {
     object_t **shadowstack, **shadowstack_base;
+    object_t *thread_local_obj;
     int associated_segment_num;
     ...;
 } stm_thread_local_t;
@@ -465,3 +466,11 @@
             addr = lib._stm_get_segment_base(i)
             content = addr[int(ffi.cast("uintptr_t", obj)) + offset]
             assert content == expected_content
+
+    def get_thread_local_obj(self):
+        tl = self.tls[self.current_thread]
+        return tl.thread_local_obj
+
+    def set_thread_local_obj(self, newobj):
+        tl = self.tls[self.current_thread]
+        tl.thread_local_obj = newobj
diff --git a/c7/test/test_gcpage.py b/c7/test/test_gcpage.py
--- a/c7/test/test_gcpage.py
+++ b/c7/test/test_gcpage.py
@@ -207,3 +207,25 @@
 
     def test_reshare_if_no_longer_modified_1(self):
         self.test_reshare_if_no_longer_modified_0(invert=1)
+
+    def test_threadlocal_at_start_of_transaction(self):
+        self.start_transaction()
+        x = stm_allocate(16)
+        stm_set_char(x, 'L')
+        self.set_thread_local_obj(x)
+        self.commit_transaction()
+
+        self.start_transaction()
+        assert stm_get_char(self.get_thread_local_obj()) == 'L'
+        self.set_thread_local_obj(stm_allocate(32))
+        stm_minor_collect()
+        self.abort_transaction()
+
+        self.start_transaction()
+        assert stm_get_char(self.get_thread_local_obj()) == 'L'
+        self.set_thread_local_obj(stm_allocate(32))
+        stm_major_collect()
+        self.abort_transaction()
+
+        self.start_transaction()
+        assert stm_get_char(self.get_thread_local_obj()) == 'L'


More information about the pypy-commit mailing list