[pypy-commit] stmgc c7-refactor: Add a debugging check that fails right now if we run more than 2 threads

arigo noreply at buildbot.pypy.org
Tue Feb 25 16:53:25 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: c7-refactor
Changeset: r863:a1bc43587591
Date: 2014-02-25 16:53 +0100
http://bitbucket.org/pypy/stmgc/changeset/a1bc43587591/

Log:	Add a debugging check that fails right now if we run more than 2
	threads

diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -160,6 +160,9 @@
     STM_PSEGMENT->transaction_state = (jmpbuf != NULL ? TS_REGULAR
                                                       : TS_INEVITABLE);
     STM_SEGMENT->jmpbuf_ptr = jmpbuf;
+#ifndef NDEBUG
+    STM_PSEGMENT->running_pthread = pthread_self();
+#endif
     STM_PSEGMENT->shadowstack_at_start_of_transaction = tl->shadowstack;
     STM_SEGMENT->nursery_end = NURSERY_END;
 
@@ -340,6 +343,7 @@
 {
     assert(!_has_mutex());
     assert(STM_PSEGMENT->safe_point == SP_RUNNING);
+    assert(STM_PSEGMENT->running_pthread == pthread_self());
 
     bool has_any_overflow_object =
         (STM_PSEGMENT->objects_pointing_to_nursery != NULL);
@@ -449,6 +453,7 @@
     default:
         assert(!"abort: bad transaction_state");
     }
+    assert(STM_PSEGMENT->running_pthread == pthread_self());
 
     /* throw away the content of the nursery */
     throw_away_nursery();
diff --git a/c7/stm/core.h b/c7/stm/core.h
--- a/c7/stm/core.h
+++ b/c7/stm/core.h
@@ -5,6 +5,7 @@
 #include <string.h>
 #include <sys/mman.h>
 #include <errno.h>
+#include <pthread.h>
 
 /************************************************************/
 
@@ -117,6 +118,11 @@
 
     /* In case of abort, we restore the 'shadowstack' field. */
     object_t **shadowstack_at_start_of_transaction;
+
+    /* For debugging */
+#ifndef NDEBUG
+    pthread_t running_pthread;
+#endif
 };
 
 enum /* safe_point */ {
diff --git a/c7/stm/sync.c b/c7/stm/sync.c
--- a/c7/stm/sync.c
+++ b/c7/stm/sync.c
@@ -1,4 +1,3 @@
-#include <pthread.h>
 #include <sys/syscall.h>
 #include <sys/prctl.h>
 #include <asm/prctl.h>


More information about the pypy-commit mailing list