11

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.)

3
  • 3
    Do you see a difference between runhaskell Fail2 and runhaskell Fail2.hs? Once you've built a Fail2 executable, runhaskell might be trying to interpret it as a Haskell source file. Commented May 24, 2019 at 21:33
  • 1
    Do you have any better luck with GHC 8.6.5? Commented May 25, 2019 at 1:10
  • Trying the one with access violation on a Linux machine gives me Fail2:1:1: error: lexical error at character '\DEL' followed by some binary garbage. I think @user11228628 's guess is pretty accurate. Commented May 25, 2019 at 9:26

1 Answer 1

4

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.)

GHC 8.6.3

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.

GHC 8.6.4

With --resolver lts-13.19 (which uses GHC 8.6.4), the commands all work as expected.

GHC 8.6.5

The same for --resolver lts-13.23 (which uses GHC 8.6.5).

Solution

Just update to the newest GHC version, or at least update to ghc 8.6.4 .

Sign up to request clarification or add additional context in comments.

4 Comments

I see there's a new release of Haskell Platform available. Installing this fixes the issue. Thanks for the tip!
Is the particular issue on the GHC bug tracker?
@JeremyList: I have no idea. And I don't know how to check it, other than manually searching through hundreds of issues.
I did take a look at the release notes, and didn't see anything about such a bug having been fixed...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.