Consider the following trivial modules:
module Fail1 where
identity x = x
module Main where
import Fail1
main = print (identity 7)
I save these as Fail1.hs
and Fail2.hs
. If I try to run this program, all is well:
> runhaskell Fail2
7
But take a look at this:
> ghc -O2 --make Fail1
[1 of 1] Compiling Fail1 ( Fail1.hs, Fail1.o )
> runhaskell Fail2
_
The program now hangs forever, with ghc.exe
consuming 100% of one CPU core. What the heck?
It gets better though:
> ghc -O2 --make Fail2
[2 of 2] Compiling Main ( Fail2.hs, Fail2.o )
> runhaskell Fail2
Access violation in generated code when reading 0xffffffffffffffff
Attempting to reconstruct a stack trace...
Frame Code address
* 0x71fdd90 0x3d7ce28 C:\Program Files\Haskell Platform\8.6.3\bin\ghc.exe+0x397ce28
Er... wat?
Ironically, if I just run Fail2.exe
itself, it works perfectly:
> Fail2
7
What in the heck is going on? Am I going mad? This really, really looks like some kind of GHC bug. Can anyone else reproduce this, or is it just my system?
> ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.3
(Wow, OK. That really doesn't display much info. I'm running Windows 7 Pro 64-bit, and I believe I've installed the 64-bit build of GHC.)
This is a bug in GHC and it has been fixed in GHC 8.6.4.
I have tested it with GHC 8.6.3, GHC 8.6.4 and GHC 8.6.5 and the latter two versions work as expected.
I used the x64 Windows haskell stack, and I'm running Windows 10 with all updates installed (as of 2019-05-25.)
(For all GHC versions: wether I write runhaskell Fail2
or runhaskell Fail2.hs
doesn't make any difference.)
this works:
stack --resolver lts-13.11 runhaskell Fail2
then I compile Fail1:
stack --resolver lts-13.11 ghc -- -O2 --make Fail1
then the original runhaskell command hangs when running Fail2.
then I compile Fail2:
stack --resolver lts-13.11 ghc -- -O2 --make Fail2
then the original runhaskell command crashes, just like the question describes it.
With --resolver lts-13.19
(which uses GHC 8.6.4), the commands all work as expected.
The same for --resolver lts-13.23
(which uses GHC 8.6.5).
Just update to the newest GHC version, or at least update to ghc 8.6.4 .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With