Commit a1436544 authored by Paul Eggert's avatar Paul Eggert

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.
parent a4ed198e
......@@ -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
......
......@@ -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)
{
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment