[PATCH] [lsan] Add __lsan_disable() and __lsan_enable().

Sergey Matveev earthdok at google.com
Fri May 31 07:58:13 PDT 2013



================
Comment at: lib/asan/asan_thread.h:70
@@ -68,1 +69,3 @@
+  void disable_lsan() { lsan_disabled_++; }
+  void enable_lsan() { if (lsan_disabled_) lsan_disabled_--; }
   u32 tid() { return context_->tid; }
----------------
Alexander Potapenko wrote:
> Kostya Serebryany wrote:
> > We better have a CHECK here instead of if 
> Need CHECKs or any other kind of error reporting, see below.
done

================
Comment at: include/sanitizer/lsan_interface.h:36
@@ +35,3 @@
+};
+}
+#endif
----------------
Alexander Potapenko wrote:
> // namespace __lsan
done

================
Comment at: lib/lsan/lit_tests/TestCases/disabler.cc:4
@@ +3,3 @@
+// RUN: %clangxx_lsan -I %p/../../../../include %s -o %t
+// RUN: %t 2>&1
+
----------------
Kostya Serebryany wrote:
> is LSAN_OPTIONS exported? 
fixed

================
Comment at: lib/lsan/lit_tests/TestCases/disabler.cc:1
@@ +1,2 @@
+// Test that stack of main thread is included in the root set.
+// RUN: LSAN_OPTIONS="report_blocks=1:use_registers=0:use_stacks=0:use_globals=0:use_tls=0"
----------------
Kostya Serebryany wrote:
> Alexander Potapenko wrote:
> > Copy-paste?
> is the comment right?
fixed

================
Comment at: lib/lsan/lit_tests/TestCases/disabler.cc:12
@@ +11,3 @@
+int main() {
+  void *p;
+  {
----------------
Kostya Serebryany wrote:
> declare this as void **
> and you can use new instead of malloc
done

================
Comment at: lib/lsan/lsan_allocator.cc:47
@@ -46,2 +46,3 @@
 static THREADLOCAL AllocatorCache cache;
+static THREADLOCAL uptr disabled;
 
----------------
Alexander Potapenko wrote:
> "disabled" isn't really a descriptive name.
replaced with lsan_disabled, can't come up with a good name now

================
Comment at: lib/lsan/lsan_allocator.cc:182
@@ -176,2 +181,3 @@
 
+
 template<typename Callable>
----------------
Alexander Potapenko wrote:
> Spare newline?
fixed

================
Comment at: lib/lsan/lsan_allocator.cc:204
@@ +203,3 @@
+void __lsan_enable() {
+  if (__lsan::disabled) __lsan::disabled--;
+}
----------------
Kostya Serebryany wrote:
> Alexander Potapenko wrote:
> > I'd say you must report an error if the number of __lsan_enable() and __lsan_disable() calls mismatch.
> s/if/CHECK/
done


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



More information about the llvm-commits mailing list