Skip to content

Commit d005cfb

Browse files
committed
try fix
1 parent 17b01b6 commit d005cfb

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

test/CMakeLists.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,9 @@ file(GLOB XTENSOR_PREPROCESS_FILES files/cppy_source/*.cppy)
235235
include(${CMAKE_SOURCE_DIR}/cmake/sanitizers.cmake)
236236

237237
if(USE_SANITIZER MATCHES "memory" AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
238-
set(XTENSOR_MSAN_IGNORELIST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/msan_ignorelist.txt")
239-
set_source_files_properties(
240-
main.cpp
241-
PROPERTIES
242-
COMPILE_OPTIONS "-fsanitize-ignorelist=${XTENSOR_MSAN_IGNORELIST_FILE}"
243-
)
238+
# doctest's String union triggers MSan false positives during
239+
# static-init reporter registration. Fixed in main.cpp with
240+
# __attribute__((no_sanitize("memory"))) on doctest functions.
244241
endif()
245242

246243
# This target should only be run when the test source files have been changed.

test/main.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1+
#ifdef __clang__
2+
#if __has_feature(memory_sanitizer)
3+
// Suppress MSan false positives in doctest's String union comparison.
4+
// doctest::String uses a union of stack/heap storage; the padding
5+
// between union members is flagged as uninitialized during strcmp
6+
// inside reporter registration at static-init time.
7+
// no_sanitize("memory") suppresses the check while still allowing
8+
// shadow memory propagation for stores.
9+
#pragma clang attribute push(__attribute__((no_sanitize("memory"))), apply_to = function)
10+
#endif
11+
#endif
12+
113
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
214
#if defined(XTENSOR_DISABLE_EXCEPTIONS)
315
#define DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
416
#endif
517
#include "doctest/doctest.h"
18+
19+
#ifdef __clang__
20+
#if __has_feature(memory_sanitizer)
21+
#pragma clang attribute pop
22+
#endif
23+
#endif

test/msan_ignorelist.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)