[cfe-dev] Brainstorming: ASAN snapshots
Kostya Serebryany via cfe-dev
cfe-dev at lists.llvm.org
Mon Oct 10 16:34:07 PDT 2016
On Mon, Oct 10, 2016 at 6:45 AM, Kim Gräsman via cfe-dev <
cfe-dev at lists.llvm.org> wrote:
> Hi all,
>
> I'm debugging a memory leak in a large code base, and it's not going
> very well. Let's say I have plenty of time to think about other
> things.
>
> I was wondering if it would be possible to use the sanitizer
> infrastructure to generate memory usage snapshots, something like a
> report mapping allocation backtrace to number of outstanding
> allocations.
>
> With something like that in place, it should be easy to catch leaks
> where memory is still reachable but kept alive indefinitely. Take two
> snapshots and diff -- the backtraces growing in outstanding
> allocations are prime suspects. I think gperftools/tcmalloc has a mode
> like this, but I haven't used it myself.
>
> Is this at all feasible?
Yes. Take a look at lib/asan/asan_memory_profile.cc and
test/asan/TestCases/Linux/print_memory_profile_test.cc
It's a toy memory profiler which prints the current allocated memory
chunks.
Very close to what you are describing (if not exactly that)
I used this functionality myself in a situation similar to yours and it
helped.
> Are patches welcome?
It depends. I am currently not ready to review large refactoring in this
code because
I hope to make one myself (maybe...)
Small incremental improvements -- yes.
--kcc
> I can't say I understand
> ASAN very well, but it feels like there is basic infrastructure
> already in place for this.
>
> Thanks,
> - Kim
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161010/b3d8a595/attachment.html>
More information about the cfe-dev
mailing list