[pypy-commit] stmgc default: In tests, we don't save and restore the shadowstack correctly.
arigo
noreply at buildbot.pypy.org
Tue Aug 12 16:43:02 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r1301:e691086e6ef0
Date: 2014-08-12 16:43 +0200
http://bitbucket.org/pypy/stmgc/changeset/e691086e6ef0/
Log: In tests, we don't save and restore the shadowstack correctly.
diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -987,8 +987,16 @@
value before the transaction start. Also restore the content
of the shadowstack here. */
stm_thread_local_t *tl = pseg->pub.running_thread;
+#ifdef STM_NO_AUTOMATIC_SETJMP
+ /* In tests, we don't save and restore the shadowstack correctly.
+ Be sure to not change items below shadowstack_at_start_of_transaction.
+ There is no such restrictions in non-Python-based tests. */
+ assert(tl->shadowstack >= pseg->shadowstack_at_start_of_transaction);
+ tl->shadowstack = pseg->shadowstack_at_start_of_transaction;
+#else
stm_rewind_jmp_restore_shadowstack(tl);
assert(tl->shadowstack == pseg->shadowstack_at_start_of_transaction);
+#endif
tl->thread_local_obj = pseg->threadlocal_at_start_of_transaction;
tl->last_abort__bytes_in_nursery = bytes_in_nursery;
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -340,8 +340,8 @@
rewind_jmp_longjmp(&(tl)->rjthread)
#define stm_rewind_jmp_forget(tl) \
rewind_jmp_forget(&(tl)->rjthread)
-#define stm_rewind_jmp_restore_shadowstack(tl) \
- ((tl)->shadowstack = (struct stm_shadowentry_s *) \
+#define stm_rewind_jmp_restore_shadowstack(tl) \
+ ((tl)->shadowstack = (struct stm_shadowentry_s *) \
rewind_jmp_restore_shadowstack(&(tl)->rjthread))
/* Starting and ending transactions. stm_read(), stm_write() and
diff --git a/c7/test/test_basic.py b/c7/test/test_basic.py
--- a/c7/test/test_basic.py
+++ b/c7/test/test_basic.py
@@ -427,6 +427,19 @@
self.abort_transaction()
py.test.raises(EmptyStack, self.pop_root)
+ def test_abort_restores_shadowstack_inv(self):
+ py.test.skip("the logic to save/restore the shadowstack doesn't "
+ "work in these tests")
+ self.push_root(ffi.cast("object_t *", 1234))
+ self.start_transaction()
+ p = self.pop_root()
+ assert p == ffi.cast("object_t *", 1234)
+ self.push_root(ffi.cast("object_t *", 5678))
+ self.pop_root()
+ self.abort_transaction()
+ p = self.pop_root()
+ assert p == ffi.cast("object_t *", 1234)
+
def test_check_content_after_commit(self):
self.start_transaction()
lp1 = stm_allocate(16)
More information about the pypy-commit
mailing list