[PATCH] [LSan] Common leak checking module.

Evgeniy Stepanov eugenis at google.com
Thu May 16 04:24:54 PDT 2013



================
Comment at: lib/lsan/lsan_common.h:44
@@ +43,3 @@
+// Aligned pointers everywhere.
+const uptr kSourceAll =
+    kSourceGlobals | kSourceStacks | kSourceTLS | kSourceRegisters;
----------------
That's a misleading name. Call it kSourceAllAligned?

================
Comment at: lib/lsan/lsan_common.h:112
@@ +111,3 @@
+
+class PrintLeakedCb {
+ public:
----------------
This needs at least a comment.

================
Comment at: lib/lsan/lsan_common.cc:200
@@ +199,3 @@
+  FloodFillReachable(&frontier);
+  ProcessSpecialAllocations(&frontier);
+  FloodFillReachable(&frontier);
----------------
call it ProcessPlatformAllocations or ProcessPlatformSpecificAllocations?

================
Comment at: lib/lsan/lsan_common.cc:266
@@ +265,3 @@
+static void PrintLeaked() {
+  Printf("\nReporting individual blocks:\n");
+  ForEachChunk(PrintLeakedCb());
----------------
Why would anyone want this? Debugging the tool itself?

================
Comment at: lib/lsan/lsan_common.cc:337
@@ +336,3 @@
+  bool is_directly_leaked = (tag == TAG_DIRECTLY_LEAKED);
+  for (uptr i = 0; i < leaks_.size(); i++)
+    if (leaks_[i].stack_trace_id == stack_trace_id &&
----------------
N^2? What if I leak a single tree with 1 million nodes?

================
Comment at: lib/lsan/lsan_common.cc:355
@@ +354,3 @@
+    Printf("\nThe %llu largest leaks:\n", max_leaks);
+  InternalSort(&leaks_, leaks_.size(), IsLarger);
+  max_leaks = max_leaks > 0 ? Min(max_leaks, leaks_.size()) : leaks_.size();
----------------
N largest can be found much more efficiently than a full sort.

================
Comment at: lib/lsan/lsan_common_linux.cc:37
@@ +36,3 @@
+  internal_memset(linker_placeholder, 0, sizeof(linker_placeholder));
+  uptr linker_found = GetListOfModules(
+      reinterpret_cast<LoadedModule *>(linker_placeholder), 1, IsLinker);
----------------
Not a very good name. Should be something with "find" or "filter" in it.


http://llvm-reviews.chandlerc.com/D787



More information about the llvm-commits mailing list