emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master a143654 2/4: Simplify use of __lsan_ignore_object


From: Paul Eggert
Subject: master a143654 2/4: Simplify use of __lsan_ignore_object
Date: Mon, 3 Aug 2020 22:09:05 -0400 (EDT)

branch: master
commit a1436544ff826b8c51242f4afb7c5d485c8e2e32
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>

    Simplify use of __lsan_ignore_object
    
    * configure.ac: Use AC_CHECK_FUNCS_ONCE for __lsan_ignore_object.
    * src/buffer.c, src/data.c, src/emacs-module.c, src/regex-emacs.c:
    * src/search.c: Use __lsan_ignore_object unconditionally, and don’t
    include sanitizer/lsan_interface.h.
    * src/lisp.h (__lsan_ignore_object): Provide a dummy in the
    typical case where leak sanitization is not available.
---
 configure.ac       |  6 ++++--
 src/buffer.c       |  6 ------
 src/data.c         |  6 ------
 src/emacs-module.c |  8 --------
 src/lisp.h         | 11 +++++++++++
 src/regex-emacs.c  |  6 ------
 src/search.c       |  6 ------
 7 files changed, 15 insertions(+), 34 deletions(-)

diff --git a/configure.ac b/configure.ac
index 93463e3..4ee4517 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4512,11 +4512,13 @@ AC_CHECK_HEADERS(valgrind/valgrind.h)
 
 AC_CHECK_MEMBERS([struct unipair.unicode], [], [], [[#include <linux/kd.h>]])
 
-AC_CHECK_FUNCS_ONCE([sbrk])
+AC_CHECK_FUNCS_ONCE([__lsan_ignore_object sbrk])
 
 AC_FUNC_FORK
 
-AC_CHECK_FUNCS(snprintf __lsan_ignore_object)
+dnl AC_CHECK_FUNCS_ONCE wouldn’t be right for snprintf, which needs
+dnl the current CFLAGS etc.
+AC_CHECK_FUNCS(snprintf)
 
 dnl Check for glib.  This differs from other library checks in that
 dnl Emacs need not link to glib unless some other library is already
diff --git a/src/buffer.c b/src/buffer.c
index e441499..241f2d4 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -28,10 +28,6 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include <stdlib.h>
 #include <unistd.h>
 
-#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H
-#include <sanitizer/lsan_interface.h>
-#endif
-
 #include <verify.h>
 
 #include "lisp.h"
@@ -5087,9 +5083,7 @@ enlarge_buffer_text (struct buffer *b, ptrdiff_t delta)
 #else
   p = xrealloc (b->text->beg, new_nbytes);
 #endif
-#ifdef HAVE___LSAN_IGNORE_OBJECT
   __lsan_ignore_object (p);
-#endif
 
   if (p == NULL)
     {
diff --git a/src/data.c b/src/data.c
index 5fff52d..59d1481 100644
--- a/src/data.c
+++ b/src/data.c
@@ -23,10 +23,6 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include <math.h>
 #include <stdio.h>
 
-#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H
-#include <sanitizer/lsan_interface.h>
-#endif
-
 #include <byteswap.h>
 #include <count-one-bits.h>
 #include <count-trailing-zeros.h>
@@ -1788,9 +1784,7 @@ make_blv (struct Lisp_Symbol *sym, bool forwarded,
   set_blv_defcell (blv, tem);
   set_blv_valcell (blv, tem);
   set_blv_found (blv, false);
-#ifdef HAVE___LSAN_IGNORE_OBJECT
   __lsan_ignore_object (blv);
-#endif
   return blv;
 }
 
diff --git a/src/emacs-module.c b/src/emacs-module.c
index f571019..a0bab11 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -84,10 +84,6 @@ To add a new module function, proceed as follows:
 #include <stdlib.h>
 #include <time.h>
 
-#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H
-#include <sanitizer/lsan_interface.h>
-#endif
-
 #include "lisp.h"
 #include "bignum.h"
 #include "dynlib.h"
@@ -1103,9 +1099,7 @@ DEFUN ("module-load", Fmodule_load, Smodule_load, 1, 1, 0,
   if (module_assertions)
     {
       rt = xmalloc (sizeof *rt);
-#ifdef HAVE___LSAN_IGNORE_OBJECT
       __lsan_ignore_object (rt);
-#endif
     }
   else
     rt = &rt_pub;
@@ -1426,9 +1420,7 @@ initialize_environment (emacs_env *env, struct 
emacs_env_private *priv)
   if (module_assertions)
     {
       env = xmalloc (sizeof *env);
-#ifdef HAVE___LSAN_IGNORE_OBJECT
       __lsan_ignore_object (env);
-#endif
     }
 
   priv->pending_non_local_exit = emacs_funcall_exit_return;
diff --git a/src/lisp.h b/src/lisp.h
index fdf69ab..22ddf3e 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4789,6 +4789,17 @@ lispstpcpy (char *dest, Lisp_Object string)
   return dest + len;
 }
 
+#if (defined HAVE___LSAN_IGNORE_OBJECT \
+     && defined HAVE_SANITIZER_LSAN_INTERFACE_H)
+# include <sanitizer/lsan_interface.h>
+#else
+/* Treat *P as a non-leak.  */
+INLINE void
+__lsan_ignore_object (void const *p)
+{
+}
+#endif
+
 extern void xputenv (const char *);
 
 extern char *egetenv_internal (const char *, ptrdiff_t);
diff --git a/src/regex-emacs.c b/src/regex-emacs.c
index 1ecbc74..c44cce9 100644
--- a/src/regex-emacs.c
+++ b/src/regex-emacs.c
@@ -29,10 +29,6 @@
 
 #include <stdlib.h>
 
-#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H
-#include <sanitizer/lsan_interface.h>
-#endif
-
 #include "character.h"
 #include "buffer.h"
 #include "syntax.h"
@@ -1761,9 +1757,7 @@ regex_compile (re_char *pattern, ptrdiff_t size,
   /* Initialize the compile stack.  */
   compile_stack.stack = xmalloc (INIT_COMPILE_STACK_SIZE
                                 * sizeof *compile_stack.stack);
-#ifdef HAVE___LSAN_IGNORE_OBJECT
   __lsan_ignore_object (compile_stack.stack);
-#endif
   compile_stack.size = INIT_COMPILE_STACK_SIZE;
   compile_stack.avail = 0;
 
diff --git a/src/search.c b/src/search.c
index 7b74ff9..38c64ca 100644
--- a/src/search.c
+++ b/src/search.c
@@ -21,10 +21,6 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 
-#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H
-#include <sanitizer/lsan_interface.h>
-#endif
-
 #include "lisp.h"
 #include "character.h"
 #include "buffer.h"
@@ -619,9 +615,7 @@ newline_cache_on_off (struct buffer *buf)
          if (base_buf->newline_cache == 0)
             {
               base_buf->newline_cache = new_region_cache ();
-#ifdef HAVE___LSAN_IGNORE_OBJECT
               __lsan_ignore_object (base_buf->newline_cache);
-#endif
             }
        }
       return base_buf->newline_cache;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]