[glib/glib-2-70: 1/2] glib-private: Fix MSVC build with AddressSanitizer




commit 376c9c360d09c86219a0999a73f81435f6757c2e
Author: Seungha Yang <seungha centricular com>
Date:   Wed Oct 13 17:28:48 2021 +0900

    glib-private: Fix MSVC build with AddressSanitizer
    
    MSVC supports AddressSanitizer as well via "/fsanitize=address" option,
    but __lsan_ignore_object() equivalent feature is not supported.
    Note that there's __declspec(no_sanitize_address) specifier which
    provides a similar feature but that's not runtime behavior
    so it's not directly applicable to g_ignore_leak() family.
    
    See also https://docs.microsoft.com/en-us/cpp/sanitizers/asan-building?view=msvc-160

 glib/glib-private.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/glib/glib-private.h b/glib/glib-private.h
index 8de380d12..1b53fccc0 100644
--- a/glib/glib-private.h
+++ b/glib/glib-private.h
@@ -23,8 +23,14 @@
 #include "gstdioprivate.h"
 
 /* gcc defines __SANITIZE_ADDRESS__, clang sets the address_sanitizer
- * feature flag */
-#if defined(__SANITIZE_ADDRESS__) || g_macro__has_feature(address_sanitizer)
+ * feature flag.
+ *
+ * MSVC defines __SANITIZE_ADDRESS__ as well when AddressSanitizer
+ * is enabled but __lsan_ignore_object() equivalent method is not supported
+ * See also
+ * https://docs.microsoft.com/en-us/cpp/sanitizers/asan-building?view=msvc-160
+ */
+#if !defined(_MSC_VER) && (defined(__SANITIZE_ADDRESS__) || g_macro__has_feature(address_sanitizer))
 
 /*
  * %_GLIB_ADDRESS_SANITIZER:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]