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

Alexey Samsonov samsonov at google.com
Mon Sep 30 03:57:56 PDT 2013


Author: samsonov
Date: Mon Sep 30 05:57:56 2013
New Revision: 191662

URL: http://llvm.org/viewvc/llvm-project?rev=191662&view=rev
Log:
[LSan] Rework r191522 - treat allocations with short stack traces as live

Modified:
    compiler-rt/trunk/lib/lsan/lsan_common.cc
    compiler-rt/trunk/lib/lsan/lsan_common_linux.cc

Modified: compiler-rt/trunk/lib/lsan/lsan_common.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_common.cc?rev=191662&r1=191661&r2=191662&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_common.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan_common.cc Mon Sep 30 05:57:56 2013
@@ -295,14 +295,10 @@ static void CollectLeaksCb(uptr chunk, v
   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 {

Modified: compiler-rt/trunk/lib/lsan/lsan_common_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_common_linux.cc?rev=191662&r1=191661&r2=191662&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_common_linux.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan_common_linux.cc Mon Sep 30 05:57:56 2013
@@ -115,8 +115,12 @@ static void ProcessPlatformSpecificAlloc
   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);
     }





More information about the llvm-commits mailing list