#14669: Windows binaries sometimes throw a stack overflow. -------------------------------------+------------------------------------- Reporter: sergv | Owner: (none) Type: bug | Status: patch Priority: highest | Milestone: 8.4.1 Component: Runtime System | Version: 8.2.1 Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4343 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"a55d581f8f2923560c3444253050b13fdf2dec10/ghc" a55d581f/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="a55d581f8f2923560c3444253050b13fdf2dec10" Fix Windows stack allocations. On Windows we use the function `win32AllocStack` to do stack allocations in 4k blocks and insert a stack check afterwards to ensure the allocation returned a valid block. The problem is this function does something that by C semantics is pointless. The stack allocated value can never escape the function, and the stack isn't used so the compiler just optimizes away the entire function body. After considering a bunch of other possibilities I think the simplest fix is to just disable optimizations for the function. Alternatively inline assembly is an option but the stack check function doesn't have a very portable name as it relies on e.g. `libgcc`. Thanks to Sergey Vinokurov for helping diagnose and test. Test Plan: ./validate Reviewers: bgamari, erikd, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #14669 Differential Revision: https://phabricator.haskell.org/D4343 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14669#comment:31> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler