Illegal instruction in GHC 6.5 generated code.

Caio Marcelo cmarcelo at gmail.com
Wed Jun 21 10:18:01 EDT 2006


(If this is the wrong list for this, please tell me. I tried
Glasgow-Haskell-Bugs, but message got hold in moderation)

Hello,

Using GHC 6.5 from darcs repo ("pulled" in 19/Jun), the following
snippet of code seems to cause illegal instruction error on the
generated code. The error disappears if I use the Dummy instance on
top of Refeable. The code is from my bindings to Judy library,
revision 10752 in subversion.
http://svn.openfoundry.org/pugs/third-party/HsJudy/
http://svn.openfoundry.org/pugs/third-party/judy/            #
original C lib code

To test it you'll need to compile (./configure; make # but not
necessarily install) the original library in
third-party/judy/Judy-1.0.3. Back in HsJudy, change the Makefile to
static link option.

HsJudy$ make testmap
HsJudy$ ./testmap

Sorry, I tried to come up with an simpler instance of the problem but
didn't found one. The program depend on WordPtr which isn't available
in GHC 6.4.2, so I couldn't test it in stable version. It was tested
on my amd64, linux 2.6.16 and in audreyt's machine (OSX I think).

---------8<------------
--class Dummy a
--instance Dummy a

--instance Dummy a => Refeable a where
instance Refeable a where
    toRef a = do
        a' <- newStablePtr a
        return (ptrToWordPtr (castStablePtrToPtr a'))
    fromRef v = do
        a <- deRefStablePtr (castPtrToStablePtr (wordPtrToPtr v))
        return a

-- Don't need to StablePtr "simple" things like Int
instance Refeable Int where
    toRef i = return $ toEnum i
    fromRef v = return $ fromEnum v
---------->8-------------


Thanks in advance,

-- 
Caio Marcelo


More information about the Glasgow-haskell-users mailing list