Compile with ASAN/UBSAN?
huitema opened this issue · 2 comments
huitema commented
Do we have a way to enable sanitizers when compiling picotls? I see the lines:
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer-no-link")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer-no-link")
in the file CMakeList.txt
, but they are only used when building under a fuzzing environment.
I would like to build the library with the sanitizers turned on, so I could link it with picoquic
and detect possible misuse of the picotls
API when testing or fuzzing picoquic. Any suggestion?
gfx commented
Hello!
That's what I did recently for CI:
https://github.com/h2o/picotls/blob/2c46de3/.github/workflows/ci.yml#L23
i.e. passing these options to cmake
:
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS=-fsanitize=address,undefined -DCMAKE_CXX_FLAGS=-fsanitize=address,undefined ...
BTW I recommend using clang
with sanitizers because I've had troubles in the combination of GCC and ASan & UBSan (I didn't dig into the GCC + sanitizers' problem, though).