couple of valgrind error squash patches

Noel Power nopower at suse.com
Tue Jan 10 20:37:56 UTC 2017


On 10/01/17 16:59, Stefan Metzmacher wrote:
> Hi Noel,
>
>> Please have a look and push if they are ok
> I think the tdgram_bsd_recvfrom_handler change is wrong.
>
> tdgram_bsd_recvfrom_recv() only returns a buffer that's
> filled by recvfrom() and the talloc_realloc() truncates
> the buffer. So the memset writes behind the buffer,
urgh, I only patched the talloc_realloc as an afterthought (wasn't
flagged by valgrind) I completely misunderstood the text in the
preceding comment and took it that it expanded the buffer :(
> it may not be noticed by valgrind if talloc isn't build
> with valgrind support and the caller uses a talloc_pool.
not sure I understand, are you saying that the earlier talloc_zero_array
isn't necessary then ? (and that valgrind is giving a false positive)
Even if so I would have said it's worth keeping the patch with the
talloc_zero_array (attached new version with the realloc/memset part
removed) note: lots of the the torture tests for me triggered this error
and it is causing lots of noise.
The problem is right now I cannot reproduce this (even though I have a
pile of logs from previous runs showing the error for various tests)
and.... I was able to reproduce it at ease earlier today so... I am not
sure even what to say (and would love if someone could explain this
strangeness to me)
> However I think there's a small memory leak in
> tdgram_bsd_recvfrom_handler().
>
>         if (retry) {
>                 /* retry later */
>                 return;
>         }
>
> Before the return we should call
> state->len = 0;
> TALLOC_FREE(state->buf);
I might be missing something but afaics state->buf isn't allocated
before the test you mention above, but... now I fear I am missing
something really obvious :/

Noel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-valgrind.diff
Type: text/x-patch
Size: 4597 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20170110/c0ae9b91/fix-valgrind.bin>


More information about the samba-technical mailing list