Commit c3b53559 authored by Philipp Stephani's avatar Philipp Stephani

Suppress leak detector in some cases

We intentionally leak some objects.  Prevent the ASan leak detector
from raising false alarms in these cases.

* configure.ac: Search for lsan_interface.h header.

* src/data.c (make_blv): Allow leaking of buffer-local values.

* src/buffer.c (enlarge_buffer_text): Allow leaking of buffer text.

* src/emacs-module.c (Fmodule_load, initialize_environment): Allow
intentional leak of runtime and environment objects if module
assertions are enabled.
parent 89127266
Pipeline #6185 failed with stage
in 10 seconds
......@@ -1740,7 +1740,8 @@ AC_CHECK_HEADERS_ONCE(
sys/sysinfo.h
coff.h pty.h
sys/resource.h
sys/utsname.h pwd.h utmp.h util.h)
sys/utsname.h pwd.h utmp.h util.h
sanitizer/lsan_interface.h)
AC_CACHE_CHECK([for ADDR_NO_RANDOMIZE],
[emacs_cv_personality_addr_no_randomize],
......
......@@ -28,6 +28,10 @@ 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"
......@@ -5083,6 +5087,9 @@ enlarge_buffer_text (struct buffer *b, ptrdiff_t delta)
#else
p = xrealloc (b->text->beg, new_nbytes);
#endif
#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H
__lsan_ignore_object (p);
#endif
if (p == NULL)
{
......
......@@ -23,6 +23,10 @@ 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>
......@@ -1784,6 +1788,9 @@ 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_SANITIZER_LSAN_INTERFACE_H
__lsan_ignore_object (blv);
#endif
return blv;
}
......
......@@ -84,6 +84,10 @@ 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"
......@@ -1095,7 +1099,16 @@ DEFUN ("module-load", Fmodule_load, Smodule_load, 1, 1, 0,
for two different runtime objects are guaranteed to be distinct,
which we can use for checking the liveness of runtime
pointers. */
struct emacs_runtime *rt = module_assertions ? xmalloc (sizeof *rt) : &rt_pub;
struct emacs_runtime *rt;
if (module_assertions)
{
rt = xmalloc (sizeof *rt);
#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H
__lsan_ignore_object (rt);
#endif
}
else
rt = &rt_pub;
rt->size = sizeof *rt;
rt->private_members = &rt_priv;
rt->get_environment = module_get_environment;
......@@ -1411,7 +1424,10 @@ static emacs_env *
initialize_environment (emacs_env *env, struct emacs_env_private *priv)
{
if (module_assertions)
{
env = xmalloc (sizeof *env);
__lsan_ignore_object (env);
}
priv->pending_non_local_exit = emacs_funcall_exit_return;
initialize_storage (&priv->storage);
......
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