[pypy-commit] stmgc c8-hashtable: Fix _stm_segfault_expected to start at 1 instead of incrementing it

arigo noreply at buildbot.pypy.org
Thu Mar 12 17:07:16 CET 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: c8-hashtable
Changeset: r1729:3b9fbd70b11f
Date: 2015-03-12 17:04 +0100
http://bitbucket.org/pypy/stmgc/changeset/3b9fbd70b11f/

Log:	Fix _stm_segfault_expected to start at 1 instead of incrementing it
	in stm_register_thread_local(). The latter ends up having all the
	tests run with a large value in _stm_segfault_expected, which is
	thus never <= 0.

diff --git a/c8/stm/gcpage.c b/c8/stm/gcpage.c
--- a/c8/stm/gcpage.c
+++ b/c8/stm/gcpage.c
@@ -142,13 +142,12 @@
     uintptr_t nobj = (uintptr_t)np;
     dprintf(("allocate_preexisting: %p\n", (object_t *)nobj));
 
-    DEBUG_EXPECT_SEGFAULT(false);
-
     char *nobj_seg0 = stm_object_pages + nobj;
     memcpy(nobj_seg0, initial_data, size_rounded_up);
     ((struct object_s *)nobj_seg0)->stm_flags = GCFLAG_WRITE_BARRIER;
 
     acquire_privatization_lock(STM_SEGMENT->segment_num);
+    DEBUG_EXPECT_SEGFAULT(false);
 
     long j;
     for (j = 1; j < NB_SEGMENTS; j++) {
@@ -173,11 +172,11 @@
 #endif
     }
 
+    DEBUG_EXPECT_SEGFAULT(true);
     release_privatization_lock(STM_SEGMENT->segment_num);
 
     write_fence();     /* make sure 'nobj' is fully initialized from
                           all threads here */
-    DEBUG_EXPECT_SEGFAULT(true);
     return (object_t *)nobj;
 }
 
diff --git a/c8/stm/hashtable.c b/c8/stm/hashtable.c
--- a/c8/stm/hashtable.c
+++ b/c8/stm/hashtable.c
@@ -150,7 +150,7 @@
                                   uintptr_t biggercount,
                                   int remove_unread_from_seg)
 {
-    dprintf(("rehash %p to %ld, remove_unread_from_seg=%d\n",
+    dprintf(("rehash %p to size %ld, remove_unread_from_seg=%d\n",
              hashtable, biggercount, remove_unread_from_seg));
 
     size_t size = (offsetof(stm_hashtable_table_t, items)
diff --git a/c8/stm/setup.c b/c8/stm/setup.c
--- a/c8/stm/setup.c
+++ b/c8/stm/setup.c
@@ -250,8 +250,6 @@
     set_gs_register(get_segment_base(num + 1));
     s_mutex_unlock();
 
-    DEBUG_EXPECT_SEGFAULT(true);
-
     if (num == 0) {
         dprintf(("STM_GC_NURSERY: %d\n", STM_GC_NURSERY));
         dprintf(("NB_PAGES: %d\n", NB_PAGES));
diff --git a/c8/stm/setup.h b/c8/stm/setup.h
--- a/c8/stm/setup.h
+++ b/c8/stm/setup.h
@@ -3,7 +3,7 @@
 static pthread_t *_get_cpth(stm_thread_local_t *);
 
 #ifndef NDEBUG
-static __thread long _stm_segfault_expected = 0;
+static __thread long _stm_segfault_expected = 1;
 #define DEBUG_EXPECT_SEGFAULT(v) do {if (v) _stm_segfault_expected++; else _stm_segfault_expected--;} while (0)
 #else
 #define DEBUG_EXPECT_SEGFAULT(v) {}


More information about the pypy-commit mailing list