|
From: Julian S. <js...@ac...> - 2009-02-02 09:54:39
|
> > Can you tell me what exactly I need to do to get the byte-51 undef
> > error, including details of what distro you're using?
>
> Ubuntu Gutsy and Intrepid, both x86_64, zlib-1.2.3.3-ubuntu5, although I
> can reproduce even with zlib-1.2.3. The key is to use both -O3 and
> -DUNALIGNED_OK.
Right. So on Ubuntu 8.04.2 I can easily reproduce it. Situation is now
much clearer.
This is (unfortunately) another version of the FAQ#36 issue.
Exactly why the undefinedness continues to propagate when built on
Ubuntu but not on openSUSE, I don't know, despite a couple hours
of investigation.
The error message in this case is a bit misleading:
Uninitialised byte(s) found during client check request
at 0x400787: main (minimal.c:73)
Address 0x51de87b is 51 bytes inside a block of size 193 alloc'd
at 0x4C2694E: malloc (vg_replace_malloc.c:207)
by 0x4006A6: main (minimal.c:49)
It's true that at the point this VALGRIND_CHECK_MEM_IS_DEFINED was done,
an uninitialised value was observed 51 bytes inside a block you malloced
yourself (so to speak). However, it is not correct to assume that
that byte is uninitialised as a result of that specific malloc. Another
possibility is that it was copied to that place from somewhere else, in an
uninitialised state. And if you add --track-origins=yes the original source
is stated:
Uninitialised value was created by a heap allocation
at 0x4C2694E: malloc (vg_replace_malloc.c:207)
by 0x40491C: zcalloc (zutil.c:306)
by 0x402BEB: deflateInit2_ (deflate.c:289)
by 0x402D40: deflateInit_ (deflate.c:212)
by 0x40068E: main (minimal.c:47)
which confirms it as the same source as all the other (false) uninit-value
errors that Memcheck reports in zlib-1.2.x.
So you can safely ignore it.
See http://www.valgrind.org/docs/manual/mc-manual.html#mc-manual.value
for details of Memcheck's definedness-tracking machinery.
I studied the relevant loop in zlib, at deflate.c:1106, and ended up
wondering if it is possible to rewrite it, without loss of performance,
so that it does not need to visit uninitialised memory.
J
|