Skip to content

Commit 8de7a0b

Browse files
authored
macOS: set MallocNanoZone=0 when using ASan (#149)
Suppresses an annoying warning.
1 parent ee22c0b commit 8de7a0b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cpp/cmake/sanitizers.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,13 @@ function(cpp_cc_enable_sanitizers)
133133
list(APPEND compiler_flags -fsanitize=address -fsanitize-address-use-after-scope)
134134
# Figure out where the runtime library lives
135135
cpp_cc_find_sanitizer_runtime(NAME asan OUTPUT runtime_library)
136+
if(APPLE)
137+
# Suppress and annoying "malloc: nano zone abandoned due to inability to preallocate reserved
138+
# vm space" message. See https://stackoverflow.com/a/70209891
139+
list(APPEND extra_env MallocNanoZone=0)
140+
endif()
136141
if(LLVM_SYMBOLIZER_PATH)
137-
set(extra_env "ASAN_SYMBOLIZER_PATH=${LLVM_SYMBOLIZER_PATH}")
142+
list(APPEND extra_env "ASAN_SYMBOLIZER_PATH=${LLVM_SYMBOLIZER_PATH}")
138143
if("leak" IN_LIST sanitizers)
139144
list(APPEND extra_env "LSAN_SYMBOLIZER_PATH=${LLVM_SYMBOLIZER_PATH}")
140145
endif()

0 commit comments

Comments
 (0)