Segfault when using non-moving GC with profiling
Summary
Running a program compiled for profiling with the non-moving garbage collector can result in a segfault.
Steps to reproduce
module Main where
import Control.Monad
import Control.Monad.Trans.State.Strict
import Data.IORef
main :: IO ()
main = do
ref <- newIORef ()
forever $ withIORef ref $ runStateT (pure ())
withIORef :: IORef a -> (a -> IO (b, a)) -> IO b
withIORef ref f =
readIORef ref >>= f >>= \(b, a) -> writeIORef ref a >> pure b
> ghc Main.hs -prof -with-rtsopts=-xn
> ./Main
fish: Job 1, './Main' terminated by signal SIGSEGV (Address boundary error)
Expected behavior
Running the program should not cause a segfault.
Environment
- GHC version used: 9.10.1
Optional:
- Operating System: NixOS 24.05
- System Architecture: x86_64