Page MenuHomePhabricator

[lsan] Add leak_check_at_exit flag.

Authored by earthdok on Aug 1 2013, 7:14 AM.



We needed a way to tell LSan to invoke leak checking only if __do_leak_check() is called explicitly.
This can now be achieved by setting leak_check_at_exit=false.

Diff Detail

Event Timeline

Please add a test for this.


... if leak checking is disabled, or if ...

earthdok updated this revision to Unknown Object (????).Aug 1 2013, 7:48 AM
  • added a test which I forgot to commit the previous time
samsonov accepted this revision.Aug 1 2013, 7:53 AM


12 ↗(On Diff #3130)

Do you really need this printf here?

earthdok added inline comments.Aug 1 2013, 7:56 AM
12 ↗(On Diff #3130)

Somehow atexit handlers are not invoked if main is a no-op. I didn't investigate further.

samsonov added inline comments.Aug 1 2013, 8:14 AM
12 ↗(On Diff #3130)

That is, LSan wouldn't run leak checking if main() is empty? I think it's
worth investigating.

earthdok added inline comments.Aug 6 2013, 5:39 AM
12 ↗(On Diff #3130)

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.
samsonov added inline comments.Aug 6 2013, 5:45 AM
12 ↗(On Diff #3130)

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.

earthdok added inline comments.Aug 7 2013, 3:12 AM
12 ↗(On Diff #3130)

Unfortunately it could cause the atexit handler to be installed late, and there would be discrepancy between standalone and ASan tools.

earthdok closed this revision.Dec 5 2014, 9:41 AM