[glib/wip/smcv/address-sanitizer: 1/3] glib-private: Add infrastructure to tell AddressSanitizer to ignore leaks
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/smcv/address-sanitizer: 1/3] glib-private: Add infrastructure to tell AddressSanitizer to ignore leaks
- Date: Thu, 28 Jan 2021 21:28:15 +0000 (UTC)
commit fc4e3c2d55a3473ba5d5cfaf0d771e85e21d22e0
Author: Simon McVittie <smcv collabora com>
Date: Thu Jan 28 21:01:51 2021 +0000
glib-private: Add infrastructure to tell AddressSanitizer to ignore leaks
Signed-off-by: Simon McVittie <smcv collabora com>
glib/glib-private.h | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
---
diff --git a/glib/glib-private.h b/glib/glib-private.h
index 8b7ab132e..a922b0c3b 100644
--- a/glib/glib-private.h
+++ b/glib/glib-private.h
@@ -22,6 +22,32 @@
#include "gwakeup.h"
#include "gstdioprivate.h"
+#if defined(__SANITIZE_ADDRESS__) || g_macro__has_feature(address_sanitizer)
+# define _GLIB_ADDRESS_SANITIZER
+# include <sanitizer/lsan_interface.h>
+# define g_ignore_leak(p) __lsan_ignore_object (p)
+# define g_ignore_strv_leak(sv) \
+ do \
+ { \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wshadow\"") \
+ const char * const * p = (const char * const *) sv; \
+ \
+ if (p) \
+ { \
+ g_ignore_leak (p); \
+ \
+ while (*p) \
+ g_ignore_leak (*(p++)); \
+ } \
+ _Pragma ("GCC diagnostic pop") \
+ } \
+ while (0)
+#else
+# define g_ignore_leak(p)
+# define g_ignore_strv_leak(sv)
+#endif
+
GMainContext * g_get_worker_context (void);
gboolean g_check_setuid (void);
GMainContext * g_main_context_new_with_next_id (guint next_id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]