[Pkg-gnupg-commit] [libgpg-error] 15/35: Add function gpgrt_annotate_leaked_object.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Mon Apr 25 21:47:12 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository libgpg-error.

commit 52c3606b2384f33ef30ea5ada3f187829de9dcf7
Author: Peter Wu <peter at lekensteyn.nl>
Date:   Wed Mar 23 23:23:06 2016 +0100

    Add function gpgrt_annotate_leaked_object.
    
    * src/gpg-error.h.in: add gpgrt_annotate_leaked_object to support
      marking memory as non-leaked for Clang and GCC.
    --
    This annotation can be used to mark objects as explicitly leaked such
    that it can be ignored in tools like LeakSanitizer.
    
    The GPGRT_HAVE_LEAK_SANITIZER macro is explicitly not undefined to
    support -fsanitize=leak, a user or configure script could then decide to
    add this macro when just -fsanitize=leak is given.
    
    Signed-off-by: Peter Wu <peter at lekensteyn.nl>
    
    Additional changes by -wk:
    
      - But __GNUC__ guard around the entire GPGRT_HAVE_LEAK_SANITIZER
        detection.
      - Add NEWS entry.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>
---
 NEWS               |  1 +
 src/gpg-error.h.in | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/NEWS b/NEWS
index b8d6be5..d1d21fa 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Noteworthy changes in version 1.22 (unreleased) [C17/A17/R_)
  * Interface changes relative to the 1.20 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  GPG_ERR_DB_CORRUPTED             NEW.
+ gpgrt_annotate_leaked_object     NEW inline func.
 
 
 Noteworthy changes in version 1.21 (2015-12-12) [C17/A17/R0]
diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in
index b32b4c4..f0043f3 100644
--- a/src/gpg-error.h.in
+++ b/src/gpg-error.h.in
@@ -246,10 +246,40 @@ typedef unsigned int gpg_error_t;
 # define GPGRT_HAVE_PRAGMA_GCC_PUSH 1
 #endif
 
+/* Detect LeakSanitizer (LSan) support for GCC and Clang based on
+ * whether AddressSanitizer (ASAN) is enabled via -fsanitize=address).
+ * Note that -fsanitize=leak just affect the linker options which
+ * cannot be detected here.  In that case you have to define the
+ * GPGRT_HAVE_LEAK_SANITIZER macro manually.  */
+#ifdef __GNUC__
+# ifdef __SANITIZE_ADDRESS__
+#  define GPGRT_HAVE_LEAK_SANITIZER
+# elif defined(__has_feature)
+#  if __has_feature(address_sanitizer)
+#   define GPGRT_HAVE_LEAK_SANITIZER
+#  endif
+# endif
+#endif
+
 
 /* The new name for the inline macro.  */
 #define GPGRT_INLINE GPG_ERR_INLINE
 
+#ifdef GPGRT_HAVE_LEAK_SANITIZER
+# include <sanitizer/lsan_interface.h>
+#endif
+
+/* Mark heap objects as non-leaked memory. */
+static GPGRT_INLINE void
+gpgrt_annotate_leaked_object (const void *p)
+{
+#ifdef GPGRT_HAVE_LEAK_SANITIZER
+  __lsan_ignore_object(p);
+#else
+  (void)p;
+#endif
+}
+
 

 /* Initialization function.  */
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/libgpg-error.git



More information about the Pkg-gnupg-commit mailing list