[Template-haskell] Templates + FFI + shared libs = segfault?

Robert Dockins robdockins at fastmail.fm
Thu Apr 29 20:51:27 EDT 2004


Greetings,

I'm new to Template Haskell and I'm working on a project to get my feet
wet.  I'm working on bindings for Qt using the smoke library.  (Some
info about smoke here:http://developer.kde.org/language-bindings/smoke/
).  Smoke is essentially a language independant binding library with
some introspection built in.

So, I'm trying to use the introspection features of smoke + template
haskell to generate type, class and instance declarations to model the
Qt class structure.  

The problem occurs when I try to link to the smoke shared libray at
splice time.  When I do, ghc segfaults:

ghc -c -fffi -fth smokeglue.o -lsmokeqt testtemp.hs
Loading package base ... linking ... done.
Loading object (static) smokeglue.o ... done
Loading object (dynamic) smokeqt ... done
Segmentation fault


Now this next one is really weird.  The code in the next listing doesn't
have any symbols to resolve; it doesn't even use FFI, but it still
segfaults when I link to the library (although apparently in a different
place?) :

$ ghc --make -fth main.hs
Chasing modules from: main.hs
Skipping  Template         ( ./Template.hs, ./Template.o )
Compiling Main             ( main.hs, main.o )
Loading package base ... linking ... done.
Loading package haskell98 ... linking ... done.
Loading package template-haskell ... linking ... done.
Linking ...

$ touch *.hs

$ ghc --make -fth -lsmokeqt main.hs
Chasing modules from: main.hs
Compiling Template         ( ./Template.hs, ./Template.o )
Compiling Main             ( main.hs, main.o )
Loading package base ... linking ... done.
Loading object (dynamic) smokeqt ... done
final link ... done
Loading package haskell98 ... linking ... done.
Loading package template-haskell ... linking ... done.
Segmentation fault


Other shared libs work though:

$ ghc --make -fth -lxine main.hs
Chasing modules from: main.hs
Skipping  Template         ( ./Template.hs, ./Template.o )
Compiling Main             ( main.hs, main.o )
Loading package base ... linking ... done.
Loading object (dynamic) xine ... done
final link ... done
Loading package haskell98 ... linking ... done.
Loading package template-haskell ... linking ... done.
Linking ...

I haven't been able to find any other libs that cause ghc to segfault
like this; it appears just to not like this one.  Also, if I link
against the lib normally (ie, not during a splice) it works, and the
resulting executable works as well.

My guess is that something isn't quite right with the code that links
shared libraries at splice time, but... its just a guess.

Any ideas? 

Thanks,
Robert Dockins

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org//pipermail/template-haskell/attachments/20040429/3ee07c9d/attachment-0001.bin


More information about the template-haskell mailing list