You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by da...@apache.org on 2017/01/06 19:59:05 UTC

[3/4] kudu git commit: lsan: Add macro to ignore a leaked object

lsan: Add macro to ignore a leaked object

Change-Id: I370c035e2b219de6676b99d564102d77fcaef570
Reviewed-on: http://gerrit.cloudera.org:8080/5616
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Tested-by: Kudu Jenkins


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/75806ea2
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/75806ea2
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/75806ea2

Branch: refs/heads/master
Commit: 75806ea2e91e2e1f11eeb6959f373fc7cf1728e5
Parents: 5bb5cdb
Author: Mike Percy <mp...@apache.org>
Authored: Tue Jan 3 14:21:13 2017 -0800
Committer: Mike Percy <mp...@apache.org>
Committed: Fri Jan 6 02:47:30 2017 +0000

----------------------------------------------------------------------
 src/kudu/util/debug/leak_annotations.h | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/75806ea2/src/kudu/util/debug/leak_annotations.h
----------------------------------------------------------------------
diff --git a/src/kudu/util/debug/leak_annotations.h b/src/kudu/util/debug/leak_annotations.h
index 642aa6a..2bfc3d8 100644
--- a/src/kudu/util/debug/leak_annotations.h
+++ b/src/kudu/util/debug/leak_annotations.h
@@ -17,6 +17,21 @@
 #ifndef KUDU_UTIL_DEBUG_LEAK_ANNOTATIONS_H_
 #define KUDU_UTIL_DEBUG_LEAK_ANNOTATIONS_H_
 
+// Ignore a single leaked object, given its pointer.
+// Does nothing if LeakSanitizer is not enabled.
+#define ANNOTATE_LEAKING_OBJECT_PTR(p)
+
+#if defined(__has_feature)
+#  if __has_feature(address_sanitizer)
+#    if defined(__linux__)
+
+#undef ANNOTATE_LEAKING_OBJECT_PTR
+#define ANNOTATE_LEAKING_OBJECT_PTR(p) __lsan_ignore_object(p);
+
+#    endif
+#  endif
+#endif
+
 // API definitions from LLVM lsan_interface.h
 
 extern "C" {
@@ -24,8 +39,10 @@ extern "C" {
   // be treated as non-leaks. Disable/enable pairs may be nested.
   void __lsan_disable();
   void __lsan_enable();
+
   // The heap object into which p points will be treated as a non-leak.
   void __lsan_ignore_object(const void *p);
+
   // The user may optionally provide this function to disallow leak checking
   // for the program it is linked into (if the return value is non-zero). This
   // function must be defined as returning a constant value; any behavior beyond
@@ -50,15 +67,17 @@ extern "C" {
   // __lsan_do_leak_check() or the end-of-process leak check, and is not
   // affected by them.
   int __lsan_do_recoverable_leak_check();
-}  // extern "C"
+} // extern "C"
 
 namespace kudu {
 namespace debug {
+
 class ScopedLSANDisabler {
  public:
   ScopedLSANDisabler() { __lsan_disable(); }
   ~ScopedLSANDisabler() { __lsan_enable(); }
 };
+
 } // namespace debug
 } // namespace kudu