[jhc] jhc-0.7.1, Segmentation fault

Gökhan San gsan at stillpsycho.net
Mon Aug 31 11:29:18 EDT 2009


Hi,

This is my first time using jhc; I installed the jhc-0.7.1
tarball. Below program gives a segfault at runtime:

> module Main (main) where 

> data Tree = Leaf | Branch [Tree]

> mkTree   :: Int -> Tree
> mkTree 0 = Leaf
> mkTree _ = Branch [mkTree 0]

> leaves             :: Tree -> Int
> leaves Leaf        = 1
> leaves (Branch ts) = sum $ map leaves ts

> main :: IO ()
> main = print . leaves . mkTree $ 1

$ rm -R ~/.jhc/ && jhc -o jhctest Test.lhs && ./jhctest 
jhc 0.7.1 (0.7.0-13)

<snip>

Running: gcc '-std=gnu99' -D_GNU_SOURCE '-falign-functions=4' -ffast-math -Wshadow -Wextra -Wall -Wno-unused-parameter -o jhctest jhctest_code.c -DNDEBUG -O3
Segmentation fault

$ uname -a
Linux 2.6.30-gentoo-r4 #3 SMP x86_64 Intel(R) Core(TM)2 CPU 6300 @ 1.86GHz GenuineIntel GNU/Linux


And with "-f debug -d c":
$ ./jhctest
jhctest: jhctest_code.c:809: promote: Assertion `!(((uintptr_t)(s)) & 0x1)' failed.
Aborted


It throws an exception:

static inline wptr_t A_STD A_UNUSED  A_HOT
promote(sptr_t s)
{
        assert(!ISLAZY(s));     // <- *HERE*
        assert(jhc_valid_whnf((wptr_t)s));
        return (wptr_t)s;
}

-- 

Gökhan San


More information about the jhc mailing list