diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f19bf90..7a730557 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -258,6 +258,7 @@ if(MI_DEBUG_UBSAN) if(CMAKE_BUILD_TYPE MATCHES "Debug") if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") message(STATUS "Build with undefined-behavior sanitizer (MI_DEBUG_UBSAN=ON)") + list(APPEND mi_defines MI_UBSAN=1) list(APPEND mi_cflags -fsanitize=undefined -g -fno-sanitize-recover=undefined) list(APPEND mi_libraries -fsanitize=undefined) if (NOT MI_USE_CXX) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0247c76f..01ad7a1b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -112,7 +112,7 @@ jobs: CC: clang CXX: clang++ BuildType: debug-tsan-clang-cxx - cmakeExtraArgs: -DCMAKE_BUILD_TYPE=Debug -DMI_USE_CXX=ON -DMI_DEBUG_TSAN=ON + cmakeExtraArgs: -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMI_USE_CXX=ON -DMI_DEBUG_TSAN=ON steps: - task: CMake@1 diff --git a/src/alloc.c b/src/alloc.c index d2f4a927..afd9e923 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -584,6 +584,7 @@ mi_decl_nodiscard void* mi_new_reallocn(void* p, size_t newcount, size_t size) { #ifdef __cplusplus void* _mi_externs[] = { (void*)&_mi_page_malloc, + (void*)&_mi_page_malloc_zero, (void*)&_mi_heap_malloc_zero, (void*)&_mi_heap_malloc_zero_ex, (void*)&mi_malloc, diff --git a/src/arena-abandoned.c b/src/arena-abandon.c similarity index 99% rename from src/arena-abandoned.c rename to src/arena-abandon.c index 465a074d..eaa8c7c9 100644 --- a/src/arena-abandoned.c +++ b/src/arena-abandon.c @@ -13,8 +13,6 @@ terms of the MIT license. A copy of the license can be found in the file #include "bitmap.h" #endif -typedef struct mi_arena_s mi_arena_t; - // Minimal exports for arena-abandoned. size_t mi_arena_id_index(mi_arena_id_t id); mi_arena_t* mi_arena_from_index(size_t idx); diff --git a/src/arena.c b/src/arena.c index 9111243e..d2039623 100644 --- a/src/arena.c +++ b/src/arena.c @@ -62,7 +62,7 @@ static mi_decl_cache_align _Atomic(mi_arena_t*) mi_arenas[MI_MAX_ARENAS]; static mi_decl_cache_align _Atomic(size_t) mi_arena_count; // = 0 #define MI_IN_ARENA_C -#include "arena-abandoned.c" +#include "arena-abandon.c" #undef MI_IN_ARENA_C /* ----------------------------------------------------------- diff --git a/test/test-stress.c b/test/test-stress.c index c6a64130..1e144bd0 100644 --- a/test/test-stress.c +++ b/test/test-stress.c @@ -25,14 +25,21 @@ terms of the MIT license. // > mimalloc-test-stress [THREADS] [SCALE] [ITER] // // argument defaults -#if !defined(MI_TSAN) +#if defined(MI_TSAN) // with thread-sanitizer reduce the threads to test within the azure pipeline limits +static int THREADS = 8; +static int SCALE = 25; +static int ITER = 200; +#elif defined(MI_UBSAN) // with undefined behavious sanitizer reduce parameters to stay within the azure pipeline limits +static int THREADS = 8; +static int SCALE = 25; +static int ITER = 20; +#else static int THREADS = 32; // more repeatable if THREADS <= #processors -#else // with thread-sanitizer reduce the defaults for azure pipeline limits -static int THREADS = 8; -#endif - static int SCALE = 25; // scaling factor static int ITER = 50; // N full iterations destructing and re-creating all threads +#endif + + #define STRESS // undefine for leak test