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

Simon Marlow simonmar at microsoft.com
Fri May 7 10:54:55 EDT 2004


On 07 May 2004 00:09, Robert Dockins wrote:

> That appears to be the case.  ghci crashes just loading the .so
> (listings below).  After playing around, the problem seems to be with
> loading the dependancies.  If I load -lqt also (very carefully), then
> ghci doesn't crash, and, in fact, the origninal TH module also loads
> and works with the correct command line.  In short here is the scoop:
> 
> 
> ghci -lsmokeqt                              segfault
> ghci -lqt -lsmokeqt                        can't find .so
> ghci -L/usr/qt/3/lib -lqt -lsmokeqt     works!
> ghci -L/usr/qt/3/lib -lsmokeqt -lqt     segfaults
> ghci -lqt                                   can't find .so
> ghci -L/usr/qt/3/lib -lqt                 works

Before we dig into this, could you try a simple C program which just
calls dlopen() on smokeqt, and see if that fails?  It looks from your
diagnosis that this is perhaps not related to GHC at all, but something
between the dynamic linker and smoke.

> So, it appears that libqt.so (or libqt-mt.so also works) must be
> loaded before libsmokeqt.so.  The same thing occurs when I insert the
> above options into the command line to compile my TH module.
> 
> I am attaching output from LD_DEBUG=files listings from three
> different situations
> 
> 1) ldrun.txt           output from a simple program which uses smoke
> 2) ghcismokeqt.txt    output from ghci -lsmokeqt
> 3) ghciqtsmokeqt.txt  output from ghci -L/usr/qt/3/lib -lqt-mt
> -lsmokeqt 
> 
> 2) is the interesting one.  It cuts off after calling init on
> libsmokeqt.so.  It also contains an error while binding the symbol
> 'pthread_key_create' in the libGL module, which looks very odd. I can
> only assume this is related somehow.  The error in question looks
> like: 
> 
>      12500:	/usr/X11R6/lib/libGL.so.1: error: relocation error:
> undefined symbol: pthread_key_create (fatal)
> 
> This error does not occur in 1) nor in 3).

Perhaps the linker is failing to load a dependency?

Cheers,
	Simon


More information about the template-haskell mailing list