[sane-devel] network scanner problems

Guido Socher guido@linuxfocus.org
Tue, 7 Aug 2001 22:17:26 +0200


Has anybody seen the following problem with the net backend
in sane 1.0.5?

The xscanimage program crashes because it tries to write
data to a closed connection.
The connection is closed in the sane_read() function in
net.c because it executes this code:
  if (s->bytes_remaining == (size_t) - 1)
        {
          char ch;

          /* turn off non-blocking I/O (s->data will be closed anyhow): */
          fcntl (s->data, F_SETFL, 0);

          /* read the status byte: */
          if (read (s->data, &ch, sizeof (ch)) != 1)
            ch = SANE_STATUS_IO_ERROR;
          do_cancel (s);
          return (SANE_Status) ch;
        }

That is s->bytes_remaining is -1 and then do_cancel(s) is
called which closes the connection.
Next xscanimage (ignoring the closed connection) tries 
to set some control options using this
closed connection and that is where the sigpipe is received.

The interessting thing is that the scan as such is ok, i.e I can
see the full picture in the preview for a second.

I have the feeling that the -1 record length is used as a special
value to signal the end of the scan and unfortunately net.c
thinks that this is an error. Is that possible?

It think that is is the case because scanning directly without
the network inbetween works perfectly. 

Anybody who managed to get the network scan backend to work in
1.0.5?

Here the crash:
Program received signal SIGPIPE, Broken pipe.
0x4042e584 in write () from /lib/libc.so.6
(gdb) backtrace
#0  0x4042e584 in write () from /lib/libc.so.6
#1  0x00000020 in ?? ()
#2  0x080564bc in flush (w=0x80739fc) at sanei_wire.c:404
#3  0x080564f4 in sanei_w_set_dir (w=0x80739fc, dir=WIRE_DECODE)
    at sanei_wire.c:413
#4  0x08056557 in sanei_w_call (w=0x80739fc, procnum=5,
    w_arg=0x4001a8e0 <sanei_w_control_option_req>, arg=0xbfffd560,
    w_reply=0x4001a960 <sanei_w_control_option_reply>, reply=0xbfffd540)
    at sanei_wire.c:432
#5  0x400194cf in sane_net_control_option (handle=0x80cc488, option=22,
    action=SANE_ACTION_SET_VALUE, value=0xbfffd758, info=0x0) at net.c:806
#6  0x4031b991 in sane_dll_control_option (handle=0x80cc4b8, option=22,
    action=SANE_ACTION_SET_VALUE, value=0xbfffd758, info=0x0) at dll.c:846
#7  0x4031bc2d in sane_control_option (h=0x80cc4b8, opt=22,
    act=SANE_ACTION_SET_VALUE, val=0xbfffd758, info=0x0) at dll-s.c:34
#8  0x08050bd0 in restore_option (p=0x80df848, option=22, saved_value=0,
    valid=1) at preview.c:453
#9  0x0805135c in scan_done (p=0x80df848) at preview.c:702
#10 0x08051269 in input_available (data=0x80df848, source=10,
    cond=GDK_INPUT_READ) at preview.c:543
(gdb)

And here the debug sequence:
sane_read: max_length = 8192
sane_read: max_length = 8192
sane_read: max_length = 8192
sane_read: max_length = 8192
sane_read: next record length=4088 bytes
sane_read: max_length = 8192
sane_read: next record length=8 bytes
sane_read: max_length = 8192
sane_read: next record length=4096 bytes
sane_read: max_length = 8192
sane_read: next record length=4076 bytes
sane_read: max_length = 8192
sane_read: next record length=20 bytes
sane_read: max_length = 8192
sane_read: next record length=4096 bytes
sane_read: max_length = 8192
sane_read: next record length=3725 bytes
sane_read: max_length = 8192
sane_read: max_length = 8192
sane_read: next record length=-1 bytes
sane_cancel
sane_control_option: option 4, action 1
sane_get_option_descriptor: option 4
sane_control_option: option 22, action 1
Broken pipe
Exit 141

-- 
The place for Linux documentation in your own language.
http://www.linuxfocus.org