Skip to content
Snippets Groups Projects
Commit 81eddb4c authored by Simon Marlow's avatar Simon Marlow
Browse files

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.
parent 6d8c5ae8
Branches
Tags
No related merge requests found
......@@ -581,6 +581,10 @@ static void
schedulePreLoop(void)
{
// initialisation for scheduler - what cannot go into initScheduler()
#if defined(mingw32_HOST_OS)
win32AllocStack();
#endif
}
/* -----------------------------------------------------------------------------
......
......@@ -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
/* ----------------------------------------------------------------------------
......
......@@ -11,4 +11,8 @@
RTS_PRIVATE StgRegTable * StgRun (StgFunPtr f, StgRegTable *basereg);
#if defined(mingw32_HOST_OS)
StgWord8 *win32AllocStack(void);
#endif
#endif /* STGRUN_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment