summaryrefslogtreecommitdiff
path: root/src/emacs-module.c
diff options
context:
space:
mode:
authorPhilipp Stephani <phst@google.com>2020-08-01 14:13:55 +0200
committerPhilipp Stephani <phst@google.com>2020-08-01 14:16:22 +0200
commitc3b53559965a4c6f48274c3cbcb43eb6ef23ae14 (patch)
tree6fe3d9675b91957a8062efd2a4f8c593ac3eec09 /src/emacs-module.c
parent89127266c93083521d71d8f2314ac88905163fd8 (diff)
downloademacs-c3b53559965a4c6f48274c3cbcb43eb6ef23ae14.tar.gz
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.
Diffstat (limited to 'src/emacs-module.c')
-rw-r--r--src/emacs-module.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c
index ac9ac824b7b..8d06a24210b 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -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);