summaryrefslogtreecommitdiff
path: root/dbus/dbus-internals.h
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2022-07-15 15:08:02 +0100
committerSimon McVittie <smcv@collabora.com>2022-07-15 15:59:38 +0100
commit5cd05bbb5a69a8d96084deafe2810d06a6f81e28 (patch)
tree1edb99175b867059a4aea4925515e8f52dd56405 /dbus/dbus-internals.h
parent9490157ef960e2d58839afbe7fe0cb8e14b010eb (diff)
downloaddbus-5cd05bbb5a69a8d96084deafe2810d06a6f81e28.tar.gz
dbus-launch-x11: Ignore X11 connection when checking for memory leaks
The X11 connection is opened and never closed. Because dbus-launch forks and continues to run non-trivial code in a forked child, it is not clear whether (or where) it would be safe to close it; instead, we leave it open until process exit, at which point the socket is cleaned up by the kernel. Any memory allocated for the X11 connection is only allocated once per run of dbus-launch, so there's no need to keep track of it, and we can silence these memory leak warnings as uninteresting. Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'dbus/dbus-internals.h')
-rw-r--r--dbus/dbus-internals.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h
index 96df3ff7..1272e8c5 100644
--- a/dbus/dbus-internals.h
+++ b/dbus/dbus-internals.h
@@ -466,6 +466,28 @@ dbus_bool_t _dbus_get_local_machine_uuid_encoded (DBusString *uuid_str,
#define _DBUS_STRINGIFY(x) #x
#define _DBUS_FILE_LINE __FILE__ ":" _DBUS_STRINGIFY(__LINE__)
+#ifndef __has_feature
+# define __has_feature(x) 0
+#endif
+
+/* MSVC defines __SANITIZE_ADDRESS__, but does not provide the special
+ * builtins associated with it. */
+#if ((defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer)) && \
+ !defined(_MSC_VER))
+# include <sanitizer/lsan_interface.h>
+/* Defined if we are building with AddressSanitizer */
+# define _DBUS_ADDRESS_SANITIZER
+/* Ignore memory allocations until the next _DBUS_END_IGNORE_LEAKS when
+ * checking for memory leaks */
+# define _DBUS_BEGIN_IGNORE_LEAKS __lsan_disable ()
+/* End the scope of a previous _DBUS_BEGIN_IGNORE_LEAKS */
+# define _DBUS_END_IGNORE_LEAKS __lsan_enable ()
+#else
+# undef _DBUS_ADDRESS_SANITIZER
+# define _DBUS_BEGIN_IGNORE_LEAKS do { } while (0)
+# define _DBUS_END_IGNORE_LEAKS do { } while (0)
+#endif
+
DBUS_END_DECLS
#endif /* DBUS_INTERNALS_H */