[PATCH] [lsan] Add leak_check_at_exit flag.

Alexey Samsonov samsonov at google.com
Wed Aug 7 03:39:05 PDT 2013


On Wed, Aug 7, 2013 at 2:12 PM, Sergey Matveev <earthdok at google.com> wrote:

>
>
> ================
> Comment at: lib/lsan/lit_tests/TestCases/leak_check_at_exit.cc:12
> @@ +11,3 @@
> +int main(int argc, char *argv[]) {
> +  printf("printf to break optimization\n");
> +  if (argc > 1)
> ----------------
> Alexey Samsonov wrote:
> > Sergey Matveev wrote:
> > > Alexey Samsonov wrote:
> > > > Sergey Matveev wrote:
> > > > > Alexey Samsonov wrote:
> > > > > > Do you really need this printf here?
> > > > > Somehow atexit handlers are not invoked if main is a no-op. I
> didn't investigate further.
> > > > That is, LSan wouldn't run leak checking if main() is empty? I think
> it's
> > > > worth investigating.
> > > >
> > > Ok, there are actually 2 separate issues here.
> > > 1. FileCheck barks at empty input (the last invocation, where we make
> sure that leak detection is not invoked, doesnt' produce any output).
> > > 2. Standalone LSan does not use preinit_array for initialization.
> Instead it initializes whenever an intercepted function is called for the
> first time. So if main() is a no-op, LSan will not print the "0 bytes
> leaked" line because we never call Init() (which is where the atexit
> handler is installed). This didn't matter before, because it used to be
> that no interceptors called = no leaks = no output. But now that we want to
> be able to print the summary even when no memory is leaked, this is no
> longer correct. Should probably fix that if only just to make it consistent
> with ASan.
> > Ah, I see. I won't bother with (2), as I assume LSan will surely
> initialize itself as soon as the first malloc() is called, so I don't think
> there's any reason in explicitly calling Init() somehow.
> Unfortunately it could cause the atexit handler to be installed late, and
> there would be discrepancy between standalone and ASan tools.
>

Looks like there's no matter when to install atexit handler for LSan (that
would run __lsan_do_leak_check) in the program, is there?
If it won't be installed, than there's no malloc in the program, and we
shouldn't care about it.


>
>
> http://llvm-reviews.chandlerc.com/D1258
>
> BRANCH
>   feat/detect_leaks_at_exit
>
> ARCANIST PROJECT
>   compiler-rt
>



-- 
Alexey Samsonov, MSK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130807/1c0eb57a/attachment.html>


More information about the llvm-commits mailing list