Harden the cmake Address Sanitizer detection code.#960
Harden the cmake Address Sanitizer detection code.#960pmqs wants to merge 6 commits intozlib-ng:developfrom
Conversation
|
The sanitizer CMake is too borrowed from zlib-ng, so I'm uncomfortable changing it. |
CMakeLists.txt
Outdated
| endif() | ||
| if(NOT MZ_STATUS) | ||
| set(MZ_SANITIZER_ENABLED OFF) | ||
| message(FATAL_ERROR "Cannot enable the Address Sanitizer '${MZ_SANITIZER}' option") |
There was a problem hiding this comment.
Let's just log "Sanitizer" without "Address", as it can be any of them.
CMakeLists.txt
Outdated
| endif() | ||
| elseif(MZ_SANITIZER_LOWER STREQUAL "none") | ||
| set(MZ_SANITIZER_ENABLED OFF) | ||
| message(STATUS " Address Sanitizer not enabled") |
There was a problem hiding this comment.
Let's just log "Sanitizer" without "Address", as it can be any of them.
CMakeLists.txt
Outdated
| add_feature_info(MZ_BUILD_UNIT_TESTS MZ_BUILD_UNIT_TESTS "Builds minizip unit test project") | ||
| add_feature_info(MZ_BUILD_FUZZ_TESTS MZ_BUILD_FUZZ_TESTS "Builds minizip fuzzer executables") | ||
| add_feature_info(MZ_CODE_COVERAGE MZ_CODE_COVERAGE "Builds with code coverage flags") | ||
| add_feature_info(MZ_SANITIZER MZ_SANITIZER_ENABLED "Builds with Address Sanitizer") |
There was a problem hiding this comment.
Let's just log "Sanitizer Support" instead of "Address Sanitizer", as it can be any of them.
The change looks good to me. @pmqs can you also offer a PR for the zlib-ng repository eventually? |
@Coeur, as it happens I'm ahead of you. Already looking at the equivalent change in zlib-ng because there is a knock-on impact with it for Sanitizer support with the Microsoft C compiler. Will write up the details in the zlib-ng PR. I'll park this change for now & get the same fix done in the much simpler zlib-ng use case sorted first. |
| add_thread_sanitizer() | ||
| elseif(MZ_SANITIZER STREQUAL "Undefined") | ||
| add_undefined_sanitizer() | ||
| message(STATUS "Checking for Address Sanitizer Option") |
There was a problem hiding this comment.
maybe remove "Address" here?
Currently the sanitizer detection code will silently ignore error cases -- like when given an unknown option or when it is asked for a valid sanitizer that isn't available for the platform. This one has stung me a few times.
This change makes it a fatal error to
One thng that dropped out with this change is the use of the Memory Sanitizer in
build.yml, Turns out that it is not available on Ubuntu, so has been adding nothing to our test coverage. I think that may be a limitation of virtualisation. I've just disabled it for now.This is what
build.ymlhad when (not) detecting the memory Sanitizer: