Opened 15 months ago

Last modified 13 months ago

#15262 new bug

GHC and iserv cannot agree on what an Integer is; insanity ensues

Reported by: howtonotwin Owned by:
Priority: high Milestone: 8.8.1
Component: Compiler Version: 8.5
Keywords: Cc:
Operating System: MacOS X Architecture: x86_64 (amd64)
Type of failure: Compile-time crash or panic Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by howtonotwin)

Tested off ghc-8.6.1-alpha1, running on macOS 10.13.5.

  1. Compile a GHC that uses integer-gmp.
  2. Compile a GHC that uses integer-simple.
  3. Make Main.hs:
    {-# LANGUAGE TemplateHaskell #-}
    main = print $([e| 0 |])
    
  4. Try to compile the file with integer-gmp ghc and integer-simple ghc-iserv.
    • Expected behavior: (compiles fine and executable prints 0) or (outputs to-the-point error message)
    • Actual:
      [1 of 1] Compiling Main             ( Main.hs, Main.o )
      
      Main.hs:2:14: error:
          • Exception when trying to run compile-time code:
              ghc: ghc-iserv terminated (-11)
            Code: [| 0 |]
          • In the untyped splice: $([| 0 |])
        |
      2 | main = print $([e| 0 |])
        |              ^^^^^^^^^^^
      
  1. Try to compile the file with integer-simple ghc and integer-gmp ghc-iserv.
    • Expected behavior: (compiles fine and executable prints 0) or (outputs to-the-point error message)
  • Actual:
    [1 of 1] Compiling Main             ( Main.hs, Main.o )
    
    Main.hs:2:14: error:
        • Exception when trying to run compile-time code:
            heap overflow
          Code: [| 0 |]
        • In the untyped splice: $([| 0 |])
      |
    2 | main = print $([e| 0 |])
      |              ^^^^^^^^^^^
    

For more fun, replace the 0 with a 1. gmp ghc + simple iserv continues to explode. This is better than simple ghc + gmp iserv:

$ ./Main
283468057265
$ ./Main
283468057265
$ $simple_ghc -fexternal-interpreter -pgmi=$gmp_iserv Main.hs # again
# ...
$ ./Main
283468057105

Absolutely delicious. There is a similar situation for fractional literals.

It would be nice if there was at least a warning for situations like this.

Change History (5)

comment:1 Changed 14 months ago by bgamari

Milestone: 8.6.18.8.1

These won't be addressed in GHC 8.6.

comment:2 Changed 14 months ago by howtonotwin

Further testing reveals that the issue is simply that the GHC distribution that created the ghc-iserv program used integer-gmp but the cross-compiler used integer-simple. Configuring the non-cross-compiling GHC to use integer-simple too fixes this. It would be nice, however, if the error message were more informative.

comment:3 Changed 14 months ago by howtonotwin

Architecture: Unknown/Multiplex86_64 (amd64)
Description: modified (diff)
Summary: TH splice containing numeric literal 0 causes heap overflow while cross-compilingGHC and iserv cannot agree on what an Integer is; insanity ensues

comment:4 Changed 14 months ago by howtonotwin

Description: modified (diff)

comment:5 Changed 13 months ago by bgamari

Priority: normalhigh

Hmmm, indeed this looks pretty terrible.

Note: See TracTickets for help on using tickets.