From 60cd538c2843827a16bf545fda93b4f2954d8e5f Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Fri, 19 Feb 2021 09:07:42 +0000 Subject: [PATCH] Change behaviour of USE_POSIX_COMMIT_CHECKS The previous setting applied USE_POSIX_COMMIT_CHECKS to snmalloc if it was a non-release build. This caused issues in CCF virtual mode, as it was being built in RelWithDebInfo. This commit changes the flag to be applied less, but for tests to always apply the setting independent of build type. This means that when snmalloc is being used as a library, it will be off, unless explicitly requested. --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24a6d53..3fd0625 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,9 +35,10 @@ size_t malloc_usable_size(const void* ptr) { return 0; } int main() { return 0; } " CONST_QUALIFIED_MALLOC_USABLE_SIZE) -if ((CMAKE_BUILD_TYPE STREQUAL "Release") AND (NOT SNMALLOC_CI_BUILD)) +if (NOT SNMALLOC_CI_BUILD) option(USE_POSIX_COMMIT_CHECKS "Instrument Posix PAL to check for access to unused blocks of memory." Off) else () + # This is enabled in every bit of CI to detect errors. option(USE_POSIX_COMMIT_CHECKS "Instrument Posix PAL to check for access to unused blocks of memory." On) endif () @@ -306,6 +307,10 @@ if(NOT DEFINED SNMALLOC_ONLY_HEADER_LIBRARY) set(TESTNAME "${TEST_CATEGORY}-${TEST}-${SUPER_SLAB_SIZE}") add_executable(${TESTNAME} ${SRC}) + + # For all tests enable commit checking. + target_compile_definitions(${TESTNAME} PRIVATE -DUSE_POSIX_COMMIT_CHECKS) + if (${SUPER_SLAB_SIZE} EQUAL 16) target_compile_definitions(${TESTNAME} PRIVATE SNMALLOC_USE_LARGE_CHUNKS) endif()