[UBsan] Added macro CDS_SUPPRESS_SANITIZE for sanitizers to suppress some warnings
authorkhizmax <libcds.dev@gmail.com>
Sun, 5 Mar 2017 19:58:47 +0000 (22:58 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sun, 5 Mar 2017 19:58:47 +0000 (22:58 +0300)
CMakeLists.txt
cds/compiler/clang/defs.h
cds/compiler/gcc/compiler_macro.h
cds/compiler/gcc/defs.h
cds/compiler/icl/defs.h
cds/compiler/vc/defs.h
cds/gc/details/retired_ptr.h
doxygen/cds.doxy
test/unit/misc/asan_errors.cpp

index 7b8c923a46c9a756d881b79b2324bc08d97ce3de..e1f1f47a58ca35fc7608fcbc1af7c2459ee89189 100644 (file)
@@ -49,7 +49,7 @@ endif(WITH_BOOST_ATOMIC)
 
 if(WITH_ASAN)
     if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1 -fPIC -fsanitize=address,undefined -g -DCDS_ASAN_ENABLED -fno-omit-frame-pointer -fno-optimize-sibling-calls")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1 -fPIC -fsanitize=address,undefined -g -DCDS_ADDRESS_SANITIZER_ENABLED -fno-omit-frame-pointer -fno-optimize-sibling-calls")
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O1 -fsanitize=address,undefined -g -DCDS_ASAN_ENABLED -fno-omit-frame-pointer -fno-optimize-sibling-calls")
         set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined -pie")
     else()
index daec9c73dfdfb0699b9b7ee825931332f9192a28..49723b2b89c92fbd94a1c2125e8c8a25f88f0667 100644 (file)
 #   define CDS_THREAD_SANITIZER_ENABLED
 #endif
 
+#if defined(__has_feature) && __has_feature(address_sanitizer)
+#   ifndef CDS_ADDRESS_SANITIZER_ENABLED
+#       define CDS_ADDRESS_SANITIZER_ENABLED
+#   endif
+#endif
+
+
 // *************************************************
 // Alignment macro
 
index df538d9fbb5764429355a960064158800286d315..3d419f48b1ca05a9b3926e894e85fc71f2234a13 100644 (file)
 #   endif
 #endif
 
+// Sanitizer attributes
+// Example: CDS_DISABLE_SANITIZE( "function" )
+#ifdef CDS_ADDRESS_SANITIZER_ENABLED
+#   define CDS_SUPPRESS_SANITIZE( ... ) __attribute__(( no_sanitize( __VA_ARGS__ ) ))
+#else
+#   define CDS_SUPPRESS_SANITIZE( ... )
+#endif
+
 
 #endif // #ifndef CDSLIB_COMPILER_GCC_COMPILER_MACRO_H
index f7e3c40381b98150b60a103e4c168e831015c04e..0d8e5c450ab0a8ec4196820219f230f00cbcc5b1 100644 (file)
 #   endif
 #endif
 
+
 #include <cds/compiler/gcc/compiler_barriers.h>
 
 #endif // #ifndef CDSLIB_COMPILER_GCC_DEFS_H
index 9417bd73109a5141ace7587156b0c94f50e8797b..322f8aa582bcc6b4a03d1ee872320ab4850a727f 100644 (file)
 #   endif
 #endif
 
+// Sanitizer attributes (not supported)
+#define CDS_SUPPRESS_SANITIZE( ... )
+
 #include <cds/compiler/icl/compiler_barriers.h>
 
 //@endcond
index 028fef0285d3c445fcc364a1bfabc77fb8515a7b..7d0b382db95b4fc54faa4b4427ee9fda45eef529 100644 (file)
 #   define CDS_ARCH_LITTLE_ENDIAN
 #endif
 
+// Sanitizer attributes (not supported)
+#define CDS_SUPPRESS_SANITIZE( ... )
+
 #include <cds/compiler/vc/compiler_barriers.h>
 
 //@endcond
index e5443704b571bff8c4f285fc869357c10921f8be..85cfce6fe35d504ad0ed32fa49fef528f3fac05e 100644 (file)
@@ -90,7 +90,7 @@ namespace cds { namespace gc {
             }
 
             /// Invokes destructor function for the pointer
-            void free()
+            void free() CDS_SUPPRESS_SANITIZE( "function" )
             {
                 assert( m_funcFree );
                 assert( m_p );
index 6bdae828edd9092c97c3650c0b3da05125ca1b91..7af7f620195a2180b7fbb92d0e18590e4c8a42d4 100644 (file)
@@ -1400,7 +1400,8 @@ PREDEFINED             = CDS_BUILD_BITS=64 \
                          CDS_NOEXCEPT=noexcept() \
                          CDS_CONSTEXPR=constexpr \
                          CDS_CXX11_INHERITING_CTOR \
-                         CDS_EXCEPTION_ENABLED
+                         CDS_EXCEPTION_ENABLED \
+                         CDS_SUPPRESS_SANITIZE
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
 # this tag can be used to specify a list of macro names that should be expanded.
index 0d991f66dfc5472d2e6c810731720ebdfb2b1f66..17ebaa87e30b224dc1c285ef17639e0ede043af6 100644 (file)
@@ -28,7 +28,7 @@
     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#ifdef CDS_ASAN_ENABLED
+#ifdef CDS_ADDRESS_SANITIZER_ENABLED
 
 #include <gtest/gtest.h>
 
@@ -76,4 +76,4 @@ namespace {
     }
 } // namespace
 
-#endif // #ifdef CDS_ASAN_ENABLED
+#endif // #ifdef CDS_ADDRESS_SANITIZER_ENABLED