[cffi-devel] Weird segfaults interfacing with libsane

Rupert Swarbrick rswarbrick at googlemail.com
Wed May 21 23:01:59 UTC 2008


Hi there,

I'm trying to use cffi to write some bindings for libsane. Having
quite some success, but for the following (rather bizarre)
problem. libsane expects: sane_init(), do some stuff, sane_exit() but
when I call sane_exit after having done anything non-trivial (for
example, called sane_get_devices), sbcl segfaults and dies.

I realise that that's not the sort of question for the cffi list,
_but_ I wrote a trivial C program that I think should be equivalent
and it doesn't die. I can't work out *how* libsane can work in one
case and not the other (!) so I was wondering if anyone could make any
suggestions. I'm attaching the two source files here.

The other piece of information is that I asked about this on #lisp a
few minutes ago, and hefner very kindly tested it out, with no
segfault at his end. I've had the same symptom with both the
asdf-installed cffi and the darcs lotsastuff branch. I presume there's
an error somewhere in my libsane config which explains why it's dying,
but I'm hoping that someone can explain how it can fail in the lisp
program and not in the C one.

Oh, it's linux i386 with SBCL from CVS this evening.

Thanks,

Rupert


-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.lisp
Type: text/lisp
Size: 559 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20080522/6668ae8f/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-csrc
Size: 205 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20080522/6668ae8f/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 306 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20080522/6668ae8f/attachment.sig>


More information about the cffi-devel mailing list