Programs loop forever when run with --nonmoving-gc on Windows using GHC 9.4.4+
Given the following program:
module Main where
main :: IO ()
main = putStrLn "Hello, World!"
If you compile this with GHC 9.4.4 or GHC 9.6.1-alpha3, you will be able to run it with the default RTS options:
$ ghc-9.4.4 Main.hs
[1 of 2] Compiling Main ( Main.hs, Main.o )
[2 of 2] Linking Main.exe
$ ./Main.exe
Hello, World!
If you try to run it with the --nonmoving-gc
RTS option, however, then the program will loop forever:
$ ./Main.exe +RTS --nonmoving-gc -RTS
Hello, World!
# The program hangs at this point, and Ctrl-C is not enough to kill it.
# The program must be manually killed with the Task Manager.
In larger applications, this bug has likely been responsible for access violations instead of infinite loops (see here for an example).
This is a regression from GHC 9.2.6, which does not exhibit this issue:
$ ghc-9.2.6 Main.hs
[1 of 1] Compiling Main ( Main.hs, Main.o )
Linking Main.exe ...
$ ./Main.exe +RTS --nonmoving-gc -RTS
Hello, World!
$ ./Main.exe
Hello, World!
Edited by Ryan Scott