[PATCH] [lsan] Add leak_check_at_exit flag.

Sergey Matveev earthdok at google.com
Tue Aug 6 05:39:39 PDT 2013



================
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:
> > > 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.


http://llvm-reviews.chandlerc.com/D1258

BRANCH
  feat/detect_leaks_at_exit

ARCANIST PROJECT
  compiler-rt



More information about the llvm-commits mailing list