[PATCH] [lsan] Add __lsan_disable() and __lsan_enable().
Alexander Potapenko
glider at google.com
Fri May 31 07:26:28 PDT 2013
================
Comment at: include/sanitizer/lsan_interface.h:36
@@ +35,3 @@
+};
+}
+#endif
----------------
// namespace __lsan
================
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"
----------------
Copy-paste?
================
Comment at: lib/lsan/lit_tests/TestCases/disabler.cc:18
@@ +17,3 @@
+ *reinterpret_cast<void **>(p) = malloc(666);
+ return 0;
+}
----------------
There's no CHECK line in this test.
================
Comment at: lib/lsan/lsan_allocator.cc:47
@@ -46,2 +46,3 @@
static THREADLOCAL AllocatorCache cache;
+static THREADLOCAL uptr disabled;
----------------
"disabled" isn't really a descriptive name.
================
Comment at: lib/lsan/lsan_allocator.cc:182
@@ -176,2 +181,3 @@
+
template<typename Callable>
----------------
Spare newline?
================
Comment at: lib/lsan/lsan_allocator.cc:204
@@ +203,3 @@
+void __lsan_enable() {
+ if (__lsan::disabled) __lsan::disabled--;
+}
----------------
I'd say you must report an error if the number of __lsan_enable() and __lsan_disable() calls mismatch.
================
Comment at: lib/lsan/lsan_allocator.cc:200
@@ +199,3 @@
+void __lsan_disable() {
+ __lsan::disabled++;
+}
----------------
Need to check for overflows.
================
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; }
----------------
Kostya Serebryany wrote:
> We better have a CHECK here instead of if
Need CHECKs or any other kind of error reporting, see below.
http://llvm-reviews.chandlerc.com/D900
More information about the llvm-commits
mailing list