
#14346: 8.2.1 regression: heap corruption after safe foreign calls -------------------------------------+------------------------------------- Reporter: andrewchen | Owner: (none) Type: bug | Status: infoneeded Priority: highest | Milestone: Component: Runtime System | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): So However, in general I wonder whether `touch#` is more unsafe than strictly necessary. It seems to me that for a tad of stack allocation you can get a much safer way to keep values alive. The trick is to introduce a primop, {{{ with# :: a -> r -> r }}} When `with# a cont` is entered, the entry code will, 1. Push an `StgWithFrame`, a new sort of return frame which carries a reference to `a`, onto the stack 2. Enters `cont` When `cont` returns, it will enter the entry code for `StgWithFrame`, which will simply pop itself and return. This way we don't need to worry about Core simplifications dropping important `touch#`s. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14346#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler