[LSan] Rework r191522 - treat allocations with short stack traces as live

llvm-svn: 191662
This commit is contained in:
Alexey Samsonov 2013-09-30 10:57:56 +00:00
parent d30ac3a125
commit 3b54a83d26
2 changed files with 8 additions and 8 deletions

View File

@ -295,14 +295,10 @@ static void CollectLeaksCb(uptr chunk, void *arg) {
LsanMetadata m(chunk);
if (!m.allocated()) return;
if (m.tag() == kDirectlyLeaked || m.tag() == kIndirectlyLeaked) {
uptr size = 0;
const uptr *trace = StackDepotGet(m.stack_trace_id(), &size);
// Ignore leaks with one-frame stack traces (which often come from
// coroutines) - they are not actionable.
if (size <= 1)
return;
uptr resolution = flags()->resolution;
if (resolution > 0) {
uptr size = 0;
const uptr *trace = StackDepotGet(m.stack_trace_id(), &size);
size = Min(size, resolution);
leak_report->Add(StackDepotPut(trace, size), m.requested_size(), m.tag());
} else {

View File

@ -115,8 +115,12 @@ static void ProcessPlatformSpecificAllocationsCb(uptr chunk, void *arg) {
LsanMetadata m(chunk);
if (m.allocated() && m.tag() != kReachable) {
u32 stack_id = m.stack_trace_id();
if (!stack_id || linker->containsAddress(GetCallerPC(
stack_id, param->stack_depot_reverse_map))) {
uptr caller_pc = 0;
if (stack_id > 0)
caller_pc = GetCallerPC(stack_id, param->stack_depot_reverse_map);
// If caller_pc is unknown, this chunk may be allocated in a coroutine. Mark
// it as reachable, as we can't properly report its allocation stack anyway.
if (caller_pc == 0 || linker->containsAddress(caller_pc)) {
m.set_tag(kReachable);
param->frontier->push_back(chunk);
}