This is an archive of the discontinued LLVM Phabricator instance.

[lsan] Ignore inderect leaks referenced by suppressed blocks
ClosedPublic

Authored by vitalybuka on Dec 28 2020, 7:54 PM.

Details

Summary

This makes suppression list to work similar to __lsan_ignore_object.

Existing behavior was inconsistent and very inconvenient for complex
data structures.

Example:

struct B;
struct A { B* ptr; };
A* t = makeA();
t->ptr = makeB();

Before the patch: if makeA suppressed by suppression file, lsan will
still report the makeB() leak, so we need two suppressions.

After the patch: a single makeA suppression is enough (the same as a
single __lsan_ignore_object(t)).

Diff Detail

Event Timeline

vitalybuka requested review of this revision.Dec 28 2020, 7:54 PM
vitalybuka created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 28 2020, 7:54 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
eugenis added inline comments.Dec 29 2020, 2:43 PM
compiler-rt/lib/lsan/lsan_common.cpp
738

If you run ApplySuppressions multiple times, would this not inflate the suppression weights (i.e. match counts)?

741

Some indication in the output that we might have failed to apply all suppressions would be good.

I hate that the algorithm may fail, but I can't offer a better idea. We could temporarily unlock the allocator while the world is stopped, symbolize all leak candidates and rerun the flood fill algorithm, but that seems dangerous.

update

compiler-rt/lib/lsan/lsan_common.cpp
738

no, the second time suppressed will have tag ignored instead of suppressed.

741

Done.

I believe you need very artificial test to hit this limit.
between each iteration program must not just leak, but also leak with unique stack which matches suppression.

avoid function local static

eugenis accepted this revision.Dec 30 2020, 1:26 PM

LGTM

This revision is now accepted and ready to land.Dec 30 2020, 1:26 PM