<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 11, 2015 at 3:00 PM, Greg Stark <span dir="ltr"><<a href="mailto:stark@mit.edu" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=stark@mit.edu&cc=&bcc=&su=&body=','_blank');return false;">stark@mit.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On Tue, Nov 10, 2015 at 5:43 PM, Greg Stark <<a href="mailto:stark@mit.edu" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=stark@mit.edu&cc=&bcc=&su=&body=','_blank');return false;">stark@mit.edu</a>> wrote:<br>
> On Mon, Nov 9, 2015 at 7:20 PM, Kostya Serebryany <<a href="mailto:kcc@google.com" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=kcc@google.com&cc=&bcc=&su=&body=','_blank');return false;">kcc@google.com</a>> wrote:<br>
>> Most likely, you need<br>
>> <a href="https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer" rel="noreferrer" target="_blank">https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer</a><br>
><br>
> Thanks!<br>
<br>
</span>This was really helpful.<br>
<br>
I have used __asan_poison_memory_region() but it's the call stack for<br>
the allocation site is based on when malloc was called. This is a<br>
random earlier allocation that allocated the pool that the chunk was<br>
returned from. Is there an API to specify the block was just allocated<br>
and to associate it with a new call stack? </blockquote><div><br></div><div>No, we never implemented that. </div><div>Feel free to file a bug (I don't think we have one), but no promises here. </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">It looks like msan does<br>
have this, __msan_allocated_memory()<br></blockquote><div><br></div><div>Correct. </div><div>msan has significantly different layout of metadata and so it was easier to implement (and more important)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
I'm also struggling with a asan report I can't explain but I think<br>
I'll write that up as a separate e-mail.<br>
<span class=""><br>
>> I don't think lsan supports this mode directly,<br>
>> but why do you think that the init-time allocations are going to be<br>
>> "leaked"?<br>
>> If there is some object still pointing to those allocations lsan will not<br>
>> complain.<br>
><br>
> Hm. That's a good point. I'm not exactly sure how the ripcord<br>
> allocator being used in Postgres combined with the asan<br>
> poison/unpoison calls would actually appear to lsan. But even aside<br>
> from that I believe there are allocations that are made early in<br>
> server initialization that are never freed and it's considered not<br>
> worth the book-keeping to free them due to the on-off nature of the<br>
> initialization.<br>
<br>
</span>Yeah. Further investigation shows that a lot of command-line parsing<br>
logic in both the main server and various other tools leak a lot of<br>
small strings here and there. There are also a number of other<br>
assorted small leaks during setup such as the SUS environ global which<br>
can't be instrumented and so on.<br>
<br>
The short story though is that in the fuzzer I just want to check that<br>
I'm not leaking memory during the fuzzer loop. I don't want to embark<br>
on the quest of eliminating memory leaks everywhere, especially during<br>
system startup and utilities. That's probably the same workflow if I<br>
wanted to use it to find leaks in the server processing loop too. I<br>
would be pretty happy if there was a way to just clear the list of<br>
allocations being tracked entirely and then start from that clean<br>
slate.<br></blockquote><div><br></div><div>Maybe you can just use suppressions for that? </div><div><br></div><div>You can also try to call __lsan_disable() very early at start up and then   __lsan_enable() before fuzzing. </div><div><span class=""><br></span></div><div><span class="">hth,</span></div><div><span class=""><br></span></div><div><span class="">--kcc </span></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class=""><font color="#888888"><br>
--<br>
greg<br>
</font></span></blockquote></div><br></div></div>