From cf10af7824101e5d24c275f6d22b26033ac73066 Mon Sep 17 00:00:00 2001 From: Daan Date: Mon, 3 Jun 2024 21:07:48 -0700 Subject: [PATCH 1/5] re-enable tsan test in azure pipelines --- azure-pipelines.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 27dfa3e1..e3689407 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -108,12 +108,11 @@ jobs: CXX: clang++ BuildType: debug-ubsan-clang cmakeExtraArgs: -DCMAKE_BUILD_TYPE=Debug -DMI_DEBUG_FULL=ON -DMI_DEBUG_UBSAN=ON - # Disable for now as it times out on the azure build machines - # Debug TSAN Clang++: - # CC: clang - # CXX: clang++ - # BuildType: debug-tsan-clang-cxx - # cmakeExtraArgs: -DCMAKE_BUILD_TYPE=Debug -DMI_USE_CXX=ON -DMI_DEBUG_TSAN=ON + Debug TSAN Clang++: + CC: clang + CXX: clang++ + BuildType: debug-tsan-clang-cxx + cmakeExtraArgs: -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMI_USE_CXX=ON -DMI_DEBUG_TSAN=ON steps: - task: CMake@1 From 0c322c556664563eea9a13b54dc7942b492d87c3 Mon Sep 17 00:00:00 2001 From: Daan Date: Mon, 3 Jun 2024 21:10:05 -0700 Subject: [PATCH 2/5] add reference to page_malloc_zero in C++ build --- src/alloc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/alloc.c b/src/alloc.c index 5ba8bb33..267fab0c 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, From b123bbe6c0e3721d363785638808a92b1175759b Mon Sep 17 00:00:00 2001 From: Daan Date: Mon, 3 Jun 2024 21:13:34 -0700 Subject: [PATCH 3/5] increase iterations for tsan test --- test/test-stress.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/test-stress.c b/test/test-stress.c index 2d1927cc..0dfa1668 100644 --- a/test/test-stress.c +++ b/test/test-stress.c @@ -27,12 +27,15 @@ terms of the MIT license. // argument defaults #if !defined(MI_TSAN) 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 +#else // with thread-sanitizer reduce the threads to test within the azure pipeline limits +static int THREADS = 8; +static int SCALE = 25; // scaling factor +static int ITER = 200; // N full iterations destructing and re-creating all threads +#endif + + #define STRESS // undefine for leak test From e0baf882bb1cfef1d0d20370de392fcd512b1fae Mon Sep 17 00:00:00 2001 From: Daan Date: Mon, 3 Jun 2024 21:26:38 -0700 Subject: [PATCH 4/5] reduce UBSAN parameters to stay within pipeline limits --- CMakeLists.txt | 1 + test/test-stress.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) 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/test/test-stress.c b/test/test-stress.c index 0dfa1668..f9b3c9d6 100644 --- a/test/test-stress.c +++ b/test/test-stress.c @@ -25,14 +25,18 @@ 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 static int SCALE = 25; // scaling factor static int ITER = 50; // N full iterations destructing and re-creating all threads -#else // with thread-sanitizer reduce the threads to test within the azure pipeline limits -static int THREADS = 8; -static int SCALE = 25; // scaling factor -static int ITER = 200; // N full iterations destructing and re-creating all threads #endif From 08fa864605a3d4d38e4ff4c44f21a72a4ada90c3 Mon Sep 17 00:00:00 2001 From: Daan Date: Mon, 3 Jun 2024 21:30:02 -0700 Subject: [PATCH 5/5] rename arena-abandoned to arena-abandon --- src/{arena-abandoned.c => arena-abandon.c} | 2 -- src/arena.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) rename src/{arena-abandoned.c => arena-abandon.c} (99%) 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 0bd58aaa..3bb8f502 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 /* -----------------------------------------------------------