[GHC] #12433: GHCi produces incorrect results when evaluating with compiled code
GHC
ghc-devs at haskell.org
Tue Jul 26 01:24:37 UTC 2016
#12433: GHCi produces incorrect results when evaluating with compiled code
-------------------------------------+-------------------------------------
Reporter: diatchki | Owner:
Type: bug | Status: new
Priority: highest | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords: ghci, dynamic
| linking, compiled code
Operating System: Linux | Architecture: x86_64
Type of failure: Incorrect result | (amd64)
at runtime | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by rwbarton):
I think it's `genSwitch` that is at fault here. It calculates the operand
adjusted for the start of the jump table with `getSomeReg`, but that
doesn't mean it is entitled to clobber the returned `reg` later, after `--
HACK: On x86_64 binutils<2.17 is only able to generate...`.
Here is a single-module reproducer that does not involve the GC. It should
be compiled with `-dynamic` (or `-fPIC`) and `-O`.
{{{#!hs
f :: Int -> IO ()
f p = case p of
0 -> return ()
1 -> return ()
2 -> return ()
3 -> return ()
4 -> return ()
10 -> return ()
11 -> return ()
_ -> print p
{-# NOINLINE f #-}
main = f 8
}}}
I had to use a value that falls into the default case, as GHC creates an
unfolding for a scrutinee that has been successfully matched against a
numeric literal and then I couldn't find any way to get the generated code
to refer to the original scrutinee.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12433#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list