[PATCH] Tests and interface for LeakSanitizer.

Sergey Matveev earthdok at google.com
Mon Apr 22 11:21:16 PDT 2013



================
Comment at: lib/lsan/lsan_testing_interface.h:1
@@ +1,2 @@
+//=-- lsan_testing_interface.h --------------------------------------------===//
+//
----------------
Kostya Serebryany wrote:
> I am confused. I thought you are going to have this in lsan.h
> Is this file only for testing lsan itself, or also for actually using lsan? 
If I merged this into lsan.h now I'd have to submit lsan.h as part of this code review, and then I'd probably have to submit lsan.cc as well. I think it would be a better idea to have this committed as a separate header, and merge it later when I'm submitting lsan proper.

================
Comment at: lib/lsan/tests/lsan_test.cc:88
@@ +87,3 @@
+
+#ifdef __x86_64__
+volatile THREADLOCAL void *tl_var;
----------------
Kostya Serebryany wrote:
> nested x86_64 ifdef? 
I'll just remove it until there's support for platforms without TLS.

================
Comment at: lib/lsan/tests/lsan_test.cc:32
@@ +31,3 @@
+uptr kMagic = 0xBABABABABABABABA;
+#define HIDE(p) ((void *)((uptr)(p) ^ kMagic))
+#define PEEK(p) HIDE(p)
----------------
Kostya Serebryany wrote:
> any reason to use macros instead of inline functions? 
We could in this case, but if they failed to inline for some reason, tests where stacks are enabled would break.

================
Comment at: lib/lsan/tests/lsan_test.cc:165
@@ +164,3 @@
+  // To prevent the compiler from optimizing out this function.
+  (void) __sync_fetch_and_xor(&locals[0], p);
+  // Hide the result, just to suppress the compiler warning.
----------------
Kostya Serebryany wrote:
> Sergey Matveev wrote:
> > Alexander Potapenko wrote:
> > > Isn't volatile enough to prevent the optimization?
> > Not in my experience.
> Please use
>  break_optimization from sanitizer_common/tests/sanitizer_test_utils.h
ok


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

BRANCH
  lsan_interface_and_tests

ARCANIST PROJECT
  compiler-rt



More information about the llvm-commits mailing list