On 16 Feb 2000, Niels Möller wrote:
> > do_zlib: Estimated size exceeded: input = 5845, estimate = 6724, output = 8201
> > do_zlib: Estimated size exceeded: input = 2979, estimate = 4377, output = 8201
> > do_zlib: Both avail_in and avail_out are zero.
> > do_zlib: deflate() or inflate() failed: No error(?)
> > read_buffered(): fd died, 1472 buffered bytes discarded
>
> I don't quite understand this. The first threee messages should be
> harmless. The fourth is printed by
>
> if (rc != Z_OK)
> {
> werror("do_zlib: deflate() or inflate() failed: %z\n",
> self->z.msg ? self->z.msg : "No error(?)");
> if (free)
> lsh_string_free(packet);
>
> return NULL;
> }
>
> in zlib.c. Could you put a breakpoint there, see what the value of rc
> really is, what the zlib-state (self->z) looks like, and see if you
> can find any more clues?
(gdb) print rc
$1 = -5 (which is Z_BUF_ERROR)
(gdb) print self->z
$2 = {next_in = 0x812149b "", avail_in = 0, total_in = 56169,
next_out = 0x810fa34 "", avail_out = 1, total_out = 66138, msg = 0x0,
state = 0x80ad534, zalloc = 0x8061758 <zlib_alloc>,
zfree = 0x8061770 <zlib_free>, opaque = 0x80497ac, data_type = 0,
adler = 368617483, reserved = 0}
(gdb) print self->f
$4 = (int (*)(struct z_stream_s *, int)) 0x80493ac <inflate>
zlib.h sais:
inflate() returns Z_OK if some progress has been made (more input processed
or more output produced), Z_STREAM_END if the end of the compressed data has
been reached and all uncompressed output has been produced, Z_NEED_DICT if a
preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
corrupted (input stream not conforming to the zlib format or incorrect
adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
(for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
enough memory, Z_BUF_ERROR if no progress is possible or if there was not
enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
case, the application may then call inflateSync to look for a good
compression block.
I've written a fprintf before doing self->f(...) and I got this in the
client at the critical point:
*** avail_in == 32783 avail_out == 32768
do_zlib: Both avail_in and avail_out are zero.
*** avail_in == 0 avail_out == 1
do_zlib: deflate() or inflate() failed: No error(?)
Here avail_out still equals to 1...
If I write self->max+1 in estimate_size, then everything works fine...
Seems, that the whole packet is inflated, which just fits the output
buffer, so both avail_in and avail_out will be 0. So we grow the output
buffer with 1 (as the limit sais this), and call inflate() again. And
inflate() thinks badly from that it has only one free byte, that it can't
progress, before it thinks about wheteher it really should progress...
Greets,
Keresztg
P.s.: BTW why doesn't the protocol itself transfers the original size of
the compressed data? Then we souldn't do guesses about how big the data
will grow...
+ Keresztfalvi Gabor
+ Student of the Budapest University of Technology and Economics
+ mailto: [EMAIL PROTECTED] [EMAIL PROTECTED]
+ http://www.sch.bme.hu/~keresztg/