Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r1144:8077f97539fc
Date: 2014-04-09 08:45 +0200
http://bitbucket.org/pypy/stmgc/changeset/8077f97539fc/

Log:    Oooops. The shadow stack is configured to contain only 1000
        entries. That's the reason PyPy crashes randomly: it overflows and
        overwrites random other data structures.

diff --git a/c7/stm/core.h b/c7/stm/core.h
--- a/c7/stm/core.h
+++ b/c7/stm/core.h
@@ -35,8 +35,6 @@
 #define WRITELOCK_START       ((END_NURSERY_PAGE * 4096UL) >> 4)
 #define WRITELOCK_END         READMARKER_END
 
-#define SHADOW_STACK_SIZE     1000
-
 enum /* stm_flags */ {
     /* This flag is set on non-nursery objects.  It forces stm_write()
        to call _stm_write_slowpath().
diff --git a/c7/stm/setup.c b/c7/stm/setup.c
--- a/c7/stm/setup.c
+++ b/c7/stm/setup.c
@@ -134,7 +134,7 @@
 static void _init_shadow_stack(stm_thread_local_t *tl)
 {
     struct stm_shadowentry_s *s = (struct stm_shadowentry_s *)
-        malloc(SHADOW_STACK_SIZE * sizeof(struct stm_shadowentry_s));
+        malloc(STM_SHADOW_STACK_DEPTH * sizeof(struct stm_shadowentry_s));
     assert(s);
     tl->shadowstack = s;
     tl->shadowstack_base = s;
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -258,6 +258,10 @@
 void stm_setup(void);
 void stm_teardown(void);
 
+/* The size of each shadow stack, in number of entries.
+   Must be big enough to accomodate all STM_PUSH_ROOTs! */
+#define STM_SHADOW_STACK_DEPTH   163840
+
 /* Push and pop roots from/to the shadow stack. Only allowed inside
    transaction. */
 #define STM_PUSH_ROOT(tl, p)   ((tl).shadowstack++->ss = (object_t *)(p))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to