[jhc] "case fell off" for trivial program

Mario Alvarez Picallo mario.alvarez739 at gmail.com
Fri May 8 20:02:55 UTC 2015


I've been looking into the generated C code. The problem seems to be caused
by an erroneous optimization that causes the tag for the variant type T3 to
be dropped altogether. This would be OK, since the other two constructors
are immediate (i.e. aren't boxed) and therefore, at runtime, you can just
check if the constructor is a pointer and if it is, then it must be T3C3,
and if it's not, check the immediate tag. However, while the representation
of the constructors is optimized, the code that checks for tags is not, and
expects T3C3 to be tagged.

If you added parameters to any other T3 constructors the optimization
wouldn't be triggered and there would be no bug.

I'm a bit hesitant to look further into this, as I'm not involved in the
development of JHC (I just happen to have some understanding of the C
backend). However, since my current project depends heavily on JHC, if
nobody else steps up I might try to fix it myself.

Cheers!

On Fri, May 8, 2015 at 6:01 PM, Herbert Valerio Riedel <hvriedel at gmail.com>
wrote:

> Hello,
>
> When compiling and running the following trivial Haskell program below w/
> jhc
> 0.8.2, it aborts right away with a "case fell off" error (see output
> below)
>
> As this seems to be a rather visible bug, is this actually a known issue?
>
> --8<---------------cut here---------------start------------->8---
> data T2 = T2C1 | T2C2 String
>          deriving (Show,Eq)
>
> data T3 = T3C1 | T3C2 | T3C3 String
>          deriving (Show,Eq)
>
> main :: IO ()
> main = do
>     print (T2C2 "works fine")
>     print (T3C3 "case falls off")
> --8<---------------cut here---------------end--------------->8---
>
>
> ...output when run:
>
> --8<---------------cut here---------------start------------->8---
> T2C2 "works fine"
>
> /tmp/jhc_8nHiAa/rts/rts_support.c:887: case fell off
> Aborted
> --8<---------------cut here---------------end--------------->8---
>
>
> Cheers,
>   hvr
> _______________________________________________
> jhc mailing list
> jhc at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/jhc
>



-- 
Now I do not know whether I was then a lambda expression emulating a Turing
machine, or whether I am a Turing machine emulating a lambda expression.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/jhc/attachments/20150508/d2f7e452/attachment.html>


More information about the jhc mailing list