[Zlib-devel] [PATCH] One remaining Valgrind error

Jan Seiffert kaffeemonster at googlemail.com
Thu Aug 16 15:03:56 EDT 2012


Daniel Richard G. schrieb:
> On Thu, 16 Aug 2012, Mark Adler wrote:
> 
>> On Aug 16, 2012, at 9:29 AM, Daniel Richard G. wrote:
>>
>> Umm, so how does a patch to deflate fix a valgrind complaint about inflate?
> 
> That kind of error was only the motivator to get zlib Valgrind-clean. (I apologize for the misdirection; that wasn't very helpful.) As Jan noted, the version of zlib in that trace is an older one, from Ubuntu/oneiric Linux; if I link against what's in git:develop, the runtest trace comes out clean. If there were no other issue, this thread wouldn't exist.
> 
> Running Valgrind on the "example" program in git:develop, however, turns up this:
> 
> ==7349== All heap blocks were freed -- no leaks are possible
> ==7349== ==7349== ERROR SUMMARY: 27189 errors from 2 contexts (suppressed: 4 from 4)
> ==7349== ==7349== 1 errors in context 1 of 2:
> ==7349== Conditional jump or move depends on uninitialised value(s)
> ==7349==    at 0x4114F3: gzputc (gzwrite.c:276)

Omph!
This is a real error:
275    have = strm->next_in + strm->avail_in - state->in;
276    if (have < state->size) {

state->in is not initialized, so "have" is bogus.

The only reason this did not crash is that avail_in is 0, so next_in is set to the
bogus in, so in - in + 0 == 0 && size == 0.

gzputc should call gz_init like the other funcs, see line 195 in gzwrite:

    /* allocate memory if this is the first time through */
    if (state->size == 0 && gz_init(state) == -1)
        return 0;

[snip]
> ==7349== ==7349== 27188 errors in context 2 of 2:
> ==7349== Conditional jump or move depends on uninitialised value(s)
> ==7349==    at 0x40512C: fill_window (deflate.c:1442)

this is in the sliding hash code.
Looks like there should be a test if this is the first hash slide?

[snip]
> 
> ("example64" gives an identical trace, but for "gzopen" being replaced by "gzopen64". The other test programs come up clean.)
> 
> The first error listed above is unique to the develop branch; it doesn't occur with git:master code.
> 
> 
> --Daniel
> 
> 

Greetings
	Jan

-- 
"You can call me Echo"





More information about the Zlib-devel mailing list