Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : ghc-7.2
http://hackage.haskell.org/trac/ghc/changeset/61458136b878afaa0f8eaf00ba0feeb945fcacbf >--------------------------------------------------------------- commit 61458136b878afaa0f8eaf00ba0feeb945fcacbf Author: Simon Marlow <[email protected]> Date: Mon Jul 18 13:48:53 2011 +0100 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. >--------------------------------------------------------------- rts/Schedule.c | 4 ++++ rts/StgCRun.c | 12 ++++++++++++ rts/StgRun.h | 4 ++++ 3 files changed, 20 insertions(+), 0 deletions(-) diff --git a/rts/Schedule.c b/rts/Schedule.c index 45959a9..50e0663 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 54ac041..69d9549 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 f277097..71b92e2 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 */ _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
