Skip to main content.
home | support | download

Back to List Archive

Re: SWISHE.pm: segfault when calling SwishErrorString()

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Mon Dec 09 2002 - 15:47:11 GMT
On Mon, 9 Dec 2002, Bernhard Weisshuhn wrote:

> Hi *,
> 
> has anything changed with SwishErrorString() in SWISHE.pm? With
> swish-e-2.2.2 (both Linux and Solaris), I get coredumps whenever I
> call SwishErrorString() on anything else than 0:
> 
> (gdb) bt
> #0  0xef4b9030 in SwishErrorString (sw=0xffffff0c) at error.c:211
> #1  0xef4ab1d4 in XS_SWISHE_SwishErrorString ()
> #2  0xa57fc in Perl_pp_entersub ()
> #3  0xe0b58 in Perl_runops_standard ()
> #4  0x65018 in perl_run ()
> #5  0x2fb48 in main ()

The swish handle is uninitialized in the call above (as I doubt 0xffffff0c
is a real address).  At what point in your perl code is it calling
SwishErrorString?  What's your perl code look like?  

If swish is returning that invalid handle the the bug is happening in a
previous call to swish-e, and that backtrace is not helpful.  My best
advice is to write a small C file that will generate the same error and
then gdb will be more helpful.

Is it possible you didn't run make insall-lib when installing 2.2.2?  I
don't think that's the problem, though.

The devel vesion of swish now installs the swish-e binary, the library and
header file, and the documentation when running "make install" so that
will avoid the problem of using the wrong version of the library (if that
is the problem you are seeing).

Anyway, try and see where that invalid handle is coming from.  Print out
the handle after ever call in perl.

It's hard to debug the swish-e code with perl because you can't set break
points until the perl module is loaded, and once it's loaded it's too
late.  Two things I do: one is to write similar code in a small C program
and then use gdb to debug.  The other is to run "make perl" when building
the module which will make a new perl binary in the local directory that
has the module linked in statically and then gdb will be more useful.  

I will note that sometimes the "make perl" thing doen't work for me -- I
think it's easier to build a small C test case if the error seems to be
inside swish-e.

By the way:

In the current development version 2.3.4 the perl interface has been
replaced.  Check out http://www.swish-e.org/dev/docs/API.html -- the OO
interface makes thing a bit more natural, plus the new() method always
returns a valid swish handle (as an object) unlike SWISHE.pm so you can
always get access to errors.  If you have not invested too much time into
SWISHE.pm you should consider using 2.3.x dev version so you will be using
the new API.

There's a replacement SWISHE.pm pure-perl module that is a thin interface
to the new SWISH::API module to allow programs that used the old SWISHE.pm
to continue to work.  That module is described in the perl/README file in
2.3.x version.


-- 
Bill Moseley moseley@hank.org
Received on Mon Dec 9 15:48:55 2002