Bug#1071658: Inconsistent --buffer-size description in manpage

2024-07-06 Thread Jörg Frings-Fürst
Hello,

thank you for spending your time helping to make Debian better with this bug
report. 


Am Donnerstag, dem 23.05.2024 um 09:04 + schrieb Ceppo:
> Package: sane-utils
> Version: 1.3.0-1
> Severity: normal
> 
> 
> Sumary: man says --buffer-size gets a value in KB, but scanimage actually
> assumes it is MB.
> 
> 
> 
> Today I tried to scan with a command that used to work until last week (when I
> updated sane-utils from 1.2.1-7+b3 to 1.3.0-1) and got an error:
> 
>    ceppo@mypc:~/Pictures/scan$ scanimage --format=png --output-file=out.png --
> resolution=300 --mode=Color
>    [07:57:39.150351] [hp5590] hp5590_bulk_read: USB-in-USB: buffer too small
>    scanimage: sane_read: Out of memory
> 
> So I tried to increase the buffer size. man says
> 
>     -B [size], --buffer-size=size
>    changes input buffer size from the default of 1MB to size KB.
> 
> and usually my scans are around 4MB each, so I tried to increase the buffer
> size to 5MB with --buffer-size=5000:
> 
>   ceppo@mypc:~/Pictures/scan$ scanimage --format=png --output-
> file=out.png --resolution=300 --mode=Color --buffer-size=5000
>     [07:58:34.930476] [hp5590] Data requested won't fit in the bulk read
> buffer (requested: 5117850, buffer size: 1048576
>     scanimage: sane_read: Out of memory
> 
> I assumed the output message uses bytes, therefore complaining about me
> requesting a 5GB buffer. So I tried --buffer-size=5 and I got my scan (4.5MB).
> 
 
The parameters -B or --buffer-size are read in with the following code:

[quote]
case 'B':
  buffer_size = 1024 * atoi(optarg);
[\quote]


The buffer is created with the following code:

[quote]
buffer = malloc (buffer_size);
[/quote]

This means that the size of the buffer is correct according to the
specifications



The error message "[hp5590] Data requested won't fit in the bulk read buffer
(requested: 5117850, buffer size: 1048576" comes from the backend hp5590

[quote]
 /* Check if requested data would fit into the buffer */
  if (size > bulk_read_state->buffer_size)
{
  DBG (DBG_err, "Data requested won't fit in the bulk read buffer "
   "(requested: %u, buffer size: %u\n", size,
   bulk_read_state->buffer_size);
  return SANE_STATUS_NO_MEM;
}
[/quote]

bulk_read_state->buffer_size is created with the following code:

[quote]
bulk_read_state->buffer_size = ALLOCATE_BULK_READ_PAGES
 * BULK_READ_PAGE_SIZE;
[/quote]


IMHO this buffer is only used to temporarily store a scanned line and the size
is determined via

[quote]
#define ALLOCATE_BULK_READ_PAGES16  /* 16 * 65536 = 1Mb */
#define BULK_READ_PAGE_SIZE 0x1
[/quote]


> I don't know what's the expected behaviour, but of course doc and actual
> behaviour should be consistent.
> 


Conclusion:

The buffer in scanimage is created in the correct size. The documentation
corresponds to the calculation (kB).


The error is probably in the backend hp5990. Please contact the developers
directly[1][2].


> Cheers,
> 
> 
> --
> Ceppo

CU
Jörg

[1] Mailinglist sane-de...@alioth-lists.debian.net
[2] https://gitlab.com/sane-project/backends/-/issues
-- 
New:
GPG Fingerprint: 63E0 075F C8D4 3ABB 35AB  30EE 09F8 9F3C 8CA1 D25D
GPG key (long) : 09F89F3C8CA1D25D
GPG Key: 8CA1D25D
CAcert Key S/N : 0E:D4:56


Jörg Frings-Fürst
D-54470 Lieser


git:  https://git.jff.email/cgit/

Skype:jff-skype@jff.email
Jami: joergfringsfuerst
Telegram: @joergfringsfuerst
Matrix:   @joergff:matrix.snct-gmbh.de

My wish list: 
 - Please send me a picture from the nature at your home.






signature.asc
Description: This is a digitally signed message part


Bug#1071658: Inconsistent --buffer-size description in manpage

2024-05-23 Thread Ceppo
Package: sane-utils
Version: 1.3.0-1
Severity: normal


Sumary: man says --buffer-size gets a value in KB, but scanimage actually
assumes it is MB.



Today I tried to scan with a command that used to work until last week (when I
updated sane-utils from 1.2.1-7+b3 to 1.3.0-1) and got an error:

   ceppo@mypc:~/Pictures/scan$ scanimage --format=png --output-file=out.png 
--resolution=300 --mode=Color
   [07:57:39.150351] [hp5590] hp5590_bulk_read: USB-in-USB: buffer too small
   scanimage: sane_read: Out of memory

So I tried to increase the buffer size. man says

-B [size], --buffer-size=size
   changes input buffer size from the default of 1MB to size KB.

and usually my scans are around 4MB each, so I tried to increase the buffer
size to 5MB with --buffer-size=5000:

ceppo@mypc:~/Pictures/scan$ scanimage --format=png 
--output-file=out.png --resolution=300 --mode=Color --buffer-size=5000
[07:58:34.930476] [hp5590] Data requested won't fit in the bulk read buffer 
(requested: 5117850, buffer size: 1048576
scanimage: sane_read: Out of memory

I assumed the output message uses bytes, therefore complaining about me
requesting a 5GB buffer. So I tried --buffer-size=5 and I got my scan (4.5MB).

I don't know what's the expected behaviour, but of course doc and actual
behaviour should be consistent.

Cheers,


--
Ceppo


signature.asc
Description: PGP signature