reassign 487475 libsane
retitle 487475 libsane: net backend option descriptors handling incorrect, 
breaking SANE standard
tags 487475 - patch
merge 487475 307088
thanks

Brad Sawatzky <[EMAIL PROTECTED]> wrote:

> The problem occurs in xsane when accessing an epson/epkowa driver through
> the network backend.  Trying to change options like binary/gray/color,
> resolutions, etc., in xsane results in a dialog box with 'Failed to set
> value of option mode: invalid argument'.  Playing with various controls
> for a while (and dismissing the errors) eventually results in the problem
> "fixing itself," after which xsane behaves normally.  There are no problems
> when accessing the same driver directly (ie. xsane + epson backend on the
> same host).

After checking the net backend code and the SANE standard, the bug is
definitely not in XSane. XSane is correct in its assumption that
option descriptors remain at the same memory location between the
sane_open and sane_close calls.

That being said, it's still a bit unclear how many bugs we are
encountering here.

The net backend only memcpy()s the option descriptors, so it's very
possible that the various strings in the option descriptors end up at
different memory addresses after a reload of the option descriptors.

Why it sometimes works and sometimes doesn't, and why this happens
pretty much only with the epson backends is not entirely clear, though
part of that can be attributed to sheer luck.

Now, I'm not entirely sure the epson backends are clear of bugs in
their handling of the option descriptors.

> Unfortunately, while the opt structure is built once and is then stable on
> the remote (epson, epkowa, whatever) backend, that memory space is NOT
> stable with the net backend.  The pointer returned by the 'opt =
> xsane_get_option_descriptor()' call in xsane.c seems to point to a
> general purpose memory buffer used by the sanei_* network routines used
> by the net backend.

The above is only partly true. The net backend allocates memory for
local option descriptors on its own, but then only memcpy()s the
options descriptors, instead of performing an in-depth copy and
duplicating the strings too.

Thus the option descriptor itself is stable but its content is not,
and the string pointers actually do point to memory allocated by
sanei_wire, as you noted.


I'm cooking up a test patch for the net backend for you to test, and
cross-checking with SANE standard lawyers :)

JB.

-- 
 Julien BLACHE - Debian & GNU/Linux Developer - <[EMAIL PROTECTED]> 
 
 Public key available on <http://www.jblache.org> - KeyID: F5D6 5169 
 GPG Fingerprint : 935A 79F1 C8B3 3521 FD62 7CC7 CD61 4FD7 F5D6 5169 



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to