diff options
author | Simon Marlow <marlowsd@gmail.com> | 2011-07-18 13:48:53 +0100 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2011-07-18 15:37:28 +0100 |
commit | 81eddb4c58c6d4171a46c727574112e2083c4878 (patch) | |
tree | 02c796458e3e8ee2dd0dc13e8de6162624478c35 | |
parent | 6d8c5ae8de842b9461551b113b8a2b59b9736ba2 (diff) | |
download | haskell-81eddb4c58c6d4171a46c727574112e2083c4878.tar.gz |
Fix Windows breakage (#5322). When I modified StgRun to use the pure
assembly version as part of the fix for #5250, we inadvertently lost
the Windows magic for extending the stack. Win32 requires that the
stack is extended a page at a time, otherwise you get a segfault. The
C compiler knows how to do this, so we now call a C stub to ensure
there's enough stack space at each invocation of the scheduler.
-rw-r--r-- | rts/Schedule.c | 4 | ||||
-rw-r--r-- | rts/StgCRun.c | 12 | ||||
-rw-r--r-- | rts/StgRun.h | 4 |
3 files changed, 20 insertions, 0 deletions
diff --git a/rts/Schedule.c b/rts/Schedule.c index 45959a92eb..50e0663577 100644 --- a/rts/Schedule.c +++ b/rts/Schedule.c @@ -581,6 +581,10 @@ static void schedulePreLoop(void) { // initialisation for scheduler - what cannot go into initScheduler() + +#if defined(mingw32_HOST_OS) + win32AllocStack(); +#endif } /* ----------------------------------------------------------------------------- diff --git a/rts/StgCRun.c b/rts/StgCRun.c index 54ac04151c..69d9549f6e 100644 --- a/rts/StgCRun.c +++ b/rts/StgCRun.c @@ -192,6 +192,18 @@ StgRunIsImplementedInAssembler(void) ); } +#if defined(mingw32_HOST_OS) +// On windows the stack has to be allocated 4k at a time, otherwise +// we get a segfault. The C compiler knows how to do this (it calls +// _alloca()), so we make sure that we can allocate as much stack as +// we need: +StgWord8 *win32AllocStack(void) +{ + StgWord8 stack[RESERVED_C_STACK_BYTES + 16 + 12]; + return stack; +} +#endif + #endif /* ---------------------------------------------------------------------------- diff --git a/rts/StgRun.h b/rts/StgRun.h index f277097df7..71b92e2d88 100644 --- a/rts/StgRun.h +++ b/rts/StgRun.h @@ -11,4 +11,8 @@ RTS_PRIVATE StgRegTable * StgRun (StgFunPtr f, StgRegTable *basereg); +#if defined(mingw32_HOST_OS) +StgWord8 *win32AllocStack(void); +#endif + #endif /* STGRUN_H */ |