[LSan] Rework r191522 - treat allocations with short stack traces as live
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@191662 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/lsan/lsan_common_linux.cc b/lib/lsan/lsan_common_linux.cc
index 6517cf1..ef8857f 100644
--- a/lib/lsan/lsan_common_linux.cc
+++ b/lib/lsan/lsan_common_linux.cc
@@ -115,8 +115,12 @@
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);
}