Page MenuHomePhabricator

[LSan] New experimental flag for background leak checking before exit.
Needs ReviewPublic

Authored by m.kashkarov on Nov 22 2017, 5:11 AM.


Group Reviewers
Restricted Project

New sanitizer option - leak_check_interval_s:
spawns a background thread at startup which periodically do recoverable leak check with given interval.
Report file names (if log_path option != stderr|stdout) are appended with prefix "in-progress" and for the DoLeakCheck() call at exit - are restores back.

This can be used for leak sanitization long-running processes that never exits.

Diff Detail

Event Timeline

m.kashkarov created this revision.Nov 22 2017, 5:11 AM
m.kashkarov edited the summary of this revision. (Show Details)

Add unimplemented in lsan mac version, update standalone lsan.

m.ostapenko added subscribers: llvm-commits, m.ostapenko.

Adding maintainers + some comments.


Why do you need all this stuff? Can't you use separate file descriptor from main report_fd? Because changing report_fd on the fly looks like a bad idea: what will happen if some another thread is reporting concurrently (corrupted reports, I guess)?


You don't need to explicitly initialize global variables with 0.

34 ↗(On Diff #124908)

Please don't. Why do you need this at all?

418 ↗(On Diff #124908)

Likewise, why do you need this?

m.kashkarov marked 4 inline comments as done.Nov 30 2017, 11:27 AM
m.kashkarov added inline comments.

If it's ok to create another file only for leak detected in the background thread - i can change the current logging behaviour.


There is build error error: uninitialized const ‘__lsan::kLeaksIntervalNotSet’ [-fpermissive] when not set to 0

34 ↗(On Diff #124908)

Oh, didn't notice that it was already included here, tested on gcc without #include "sanitizer_common/sanitizer_posix.h".

418 ↗(On Diff #124908)

This is for the real_pthread_create used in internal_start_thread.

m.kashkarov marked 4 inline comments as done.

Fixed typo error, update.

m.kashkarov marked an inline comment as not done.
alekseyshl added inline comments.Nov 30 2017, 11:33 AM

FYI, this won't work on Android (see D27003, for example). Same for LSan.

alekseyshl edited edge metadata.Nov 30 2017, 3:17 PM

Can it be implemented with timer_create() instead of the thread?

vitalybuka resigned from this revision.Dec 8 2017, 3:57 PM
m.kashkarov marked an inline comment as done.

Back to this feature, draft with signals impl.

kcc added a comment.Jul 16 2018, 12:50 PM

I'd prefer to not have this functionality in lsan -- it already has __lsan_do_recoverable_leak_check which should be sufficient for a user to implement this functionality on their side.
(If not, that may need to be fixed).