diff --git a/CMakeLists.txt b/CMakeLists.txt index 580e38cb..fc3d0d3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,8 +150,9 @@ 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_cflags -fsanitize=undefined -g) + list(APPEND mi_cflags -fsanitize=undefined -g -fno-sanitize-recover=undefined) list(APPEND CMAKE_EXE_LINKER_FLAGS -fsanitize=undefined) + list(APPEND mi_libraries ubsan) if (NOT MI_USE_CXX) message(STATUS "(switch to use C++ due to MI_DEBUG_UBSAN)") set(MI_USE_CXX "ON") diff --git a/test/test-api.c b/test/test-api.c index 8ddbf7cf..9a2c06ab 100644 --- a/test/test-api.c +++ b/test/test-api.c @@ -91,6 +91,10 @@ int main(void) { CHECK_BODY("malloc-null",{ mi_free(NULL); }); + CHECK_BODY("malloc-large",{ + void *p = mi_malloc(67108872); + mi_free(p); + }); CHECK_BODY("calloc-overflow",{ // use (size_t)&mi_calloc to get some number without triggering compiler warnings result = (mi_calloc((size_t)&mi_calloc,SIZE_MAX/1000) == NULL);