diff --git a/src/util/small_vector.h b/src/util/small_vector.h index 0f54bbf6..5bad7df9 100644 --- a/src/util/small_vector.h +++ b/src/util/small_vector.h @@ -29,7 +29,11 @@ #ifndef UTIL_SMALL_VECTOR_H #define UTIL_SMALL_VECTOR_H -#include +#if defined(__has_feature) +# if __has_feature(memory_sanitizer) +#define BUILD_WITH_MSAN +# endif +#endif #include @@ -37,8 +41,16 @@ * We use the small_vector constructors introduced in Boost 1.61 (trac bug * #11866, github commit b436c91). If the Boost version is too old, we fall * back to using std::vector. + * + * Also with MSan boost::container::small_vector cannot be used because MSan + * reports some issues there, it looks similar to [1], but even adding + * __attribute__((no_sanitize_memory)) for ~small_vector_base() [2] is not + * enough since clang-16, so let's simply use std::vector under MSan. + * + * [1]: https://github.com/google/sanitizers/issues/854 + * [2]: https://github.com/ClickHouse/boost/commit/229354100 */ -#if BOOST_VERSION >= 106100 +#if !defined(BUILD_WITH_MSAN) && BOOST_VERSION >= 106100 # define HAVE_BOOST_CONTAINER_SMALL_VECTOR #endif @@ -56,6 +68,8 @@ using small_vector = boost::container::small_vector; #else +#include + // Boost version isn't new enough, fall back to just using std::vector. template > using small_vector = std::vector;