[GHC] #15262: GHC and iserv cannot agree on what an Integer is; insanity ensues

GHC ghc-devs at haskell.org
Tue Jul 3 15:30:59 UTC 2018


#15262: GHC and iserv cannot agree on what an Integer is; insanity ensues
-------------------------------------+-------------------------------------
        Reporter:  howtonotwin       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  8.5
      Resolution:                    |             Keywords:
Operating System:  MacOS X           |         Architecture:  x86_64
 Type of failure:  Compile-time      |  (amd64)
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by howtonotwin:

Old description:

> 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`:
>    {{{#!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; executable prints `0`
>    * 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 |])
>       |              ^^^^^^^^^^^
>     }}}
>
> 4. Try to compile the file with `integer-simple` `ghc` and `integer-gmp`
> `ghc-iserv`.
>   * Expected behavior: compiles fine, executable prints `0`.
>   * 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`:
>
> {{{#!bash
> $ ./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.

New description:

 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`:
    {{{#!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 |])
       |              ^^^^^^^^^^^
     }}}

 4. 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`:

 {{{#!bash
 $ ./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.

--

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15262#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list