[sane-devel] Python bindings segfault
abel deuring
adeuring at gmx.net
Sun Jun 15 15:09:49 UTC 2008
On 15.06.2008 14:56, Albert Cervera i Areny wrote:
> While testing sane python bindings I found a segmentation fault while trying
> to open the device. I attach a couple of logs.
>
> 'sane.log' is the output of running:
> SANE_DEBUG_HP5590=50 SANE_DEBUG_SANEI_USB=255 ./test-sane.py
>
> 'valgrind.log' is the output of running my test script
> with "valgrind --trace-children=yes"
>
> The script is very simple (the device exists):
>
> import sane
> sane.init()
> sane.open( 'hp5590:libusb:004:005' )
Am I right that this is the complete Pytjon code leading to the segfault?
>
> This is running Debian unstable with the following packages:
> python-imaging-sane 1.1.6
> sane 1.0.14
> libsane 1.0.19
> plus -deb packages, as as you can see in valgrind.log
>
> Do you think this is a Debian specific problem, any other tests I could make?
Unfortunately, the C extension _sane.so does not automatically ensure
the correct sequence of the calls sane_close() and sane_exit().
(sane_close should be called for all opened devices before sane_exit; if
sane_close is called after sane_exit, weird things may happen)
sane_close isn't even called automatically -- you must do that explicitly.
Could you try something like
import sane
sane.init()
device = sane.open( 'hp5590:libusb:004:005' )
device.close()
If this does not help, can you send me gdb's "bt" output?
Abel
PS: This requirement to explicitly call device.close() bothers me since
years, but I never got of my ass to write a more "pythonic"
implementation of _sane.c ...
More information about the sane-devel
mailing list