aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhilipp Stephani2020-08-01 14:13:55 +0200
committerPhilipp Stephani2020-08-01 14:16:22 +0200
commitc3b53559965a4c6f48274c3cbcb43eb6ef23ae14 (patch)
tree6fe3d9675b91957a8062efd2a4f8c593ac3eec09 /src
parent89127266c93083521d71d8f2314ac88905163fd8 (diff)
downloademacs-c3b53559965a4c6f48274c3cbcb43eb6ef23ae14.tar.gz
emacs-c3b53559965a4c6f48274c3cbcb43eb6ef23ae14.zip
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')
-rw-r--r--src/buffer.c7
-rw-r--r--src/data.c7
-rw-r--r--src/emacs-module.c18
3 files changed, 31 insertions, 1 deletions
diff --git a/src/buffer.c b/src/buffer.c
index f1cb4d50414..3456a46be3e 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -28,6 +28,10 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
28#include <stdlib.h> 28#include <stdlib.h>
29#include <unistd.h> 29#include <unistd.h>
30 30
31#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H
32#include <sanitizer/lsan_interface.h>
33#endif
34
31#include <verify.h> 35#include <verify.h>
32 36
33#include "lisp.h" 37#include "lisp.h"
@@ -5083,6 +5087,9 @@ enlarge_buffer_text (struct buffer *b, ptrdiff_t delta)
5083#else 5087#else
5084 p = xrealloc (b->text->beg, new_nbytes); 5088 p = xrealloc (b->text->beg, new_nbytes);
5085#endif 5089#endif
5090#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H
5091 __lsan_ignore_object (p);
5092#endif
5086 5093
5087 if (p == NULL) 5094 if (p == NULL)
5088 { 5095 {
diff --git a/src/data.c b/src/data.c
index 1db0a983b49..c261e8e90dd 100644
--- a/src/data.c
+++ b/src/data.c
@@ -23,6 +23,10 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
23#include <math.h> 23#include <math.h>
24#include <stdio.h> 24#include <stdio.h>
25 25
26#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H
27#include <sanitizer/lsan_interface.h>
28#endif
29
26#include <byteswap.h> 30#include <byteswap.h>
27#include <count-one-bits.h> 31#include <count-one-bits.h>
28#include <count-trailing-zeros.h> 32#include <count-trailing-zeros.h>
@@ -1784,6 +1788,9 @@ make_blv (struct Lisp_Symbol *sym, bool forwarded,
1784 set_blv_defcell (blv, tem); 1788 set_blv_defcell (blv, tem);
1785 set_blv_valcell (blv, tem); 1789 set_blv_valcell (blv, tem);
1786 set_blv_found (blv, false); 1790 set_blv_found (blv, false);
1791#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H
1792 __lsan_ignore_object (blv);
1793#endif
1787 return blv; 1794 return blv;
1788} 1795}
1789 1796
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:
84#include <stdlib.h> 84#include <stdlib.h>
85#include <time.h> 85#include <time.h>
86 86
87#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H
88#include <sanitizer/lsan_interface.h>
89#endif
90
87#include "lisp.h" 91#include "lisp.h"
88#include "bignum.h" 92#include "bignum.h"
89#include "dynlib.h" 93#include "dynlib.h"
@@ -1095,7 +1099,16 @@ DEFUN ("module-load", Fmodule_load, Smodule_load, 1, 1, 0,
1095 for two different runtime objects are guaranteed to be distinct, 1099 for two different runtime objects are guaranteed to be distinct,
1096 which we can use for checking the liveness of runtime 1100 which we can use for checking the liveness of runtime
1097 pointers. */ 1101 pointers. */
1098 struct emacs_runtime *rt = module_assertions ? xmalloc (sizeof *rt) : &rt_pub; 1102 struct emacs_runtime *rt;
1103 if (module_assertions)
1104 {
1105 rt = xmalloc (sizeof *rt);
1106#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H
1107 __lsan_ignore_object (rt);
1108#endif
1109 }
1110 else
1111 rt = &rt_pub;
1099 rt->size = sizeof *rt; 1112 rt->size = sizeof *rt;
1100 rt->private_members = &rt_priv; 1113 rt->private_members = &rt_priv;
1101 rt->get_environment = module_get_environment; 1114 rt->get_environment = module_get_environment;
@@ -1411,7 +1424,10 @@ static emacs_env *
1411initialize_environment (emacs_env *env, struct emacs_env_private *priv) 1424initialize_environment (emacs_env *env, struct emacs_env_private *priv)
1412{ 1425{
1413 if (module_assertions) 1426 if (module_assertions)
1427 {
1414 env = xmalloc (sizeof *env); 1428 env = xmalloc (sizeof *env);
1429 __lsan_ignore_object (env);
1430 }
1415 1431
1416 priv->pending_non_local_exit = emacs_funcall_exit_return; 1432 priv->pending_non_local_exit = emacs_funcall_exit_return;
1417 initialize_storage (&priv->storage); 1433 initialize_storage (&priv->storage);