Allow clang runtime sanitizers to be used on tor unit tests
The clang runtime address sanitizer causes the memwipe and backtrace tests to fail, because it catches the undefined behavior that is invoked as an unavoidable part of these tests.
This issue can be resolved by:
- blacklisting the involved functions so the sanitizer doesn't check them, by adding to the command line
-fsanitize-blacklist=sanitize_blacklist.txt
containing:
# test-memwipe.c checks if a freed buffer was properly wiped
fun:vmemeq
# test_bt_cl.c stores to a NULL pointer to trigger a crash
fun:crash
# we need to exempt the entire file, otherwise address sanitizer munges
# the expected output
src:test_bt_cl.c
- allowing the backtrace handler to catch SIGSEGV (rather than address sanitizer), by setting the environmental variable
ASAN_OPTIONS=allow_user_segv_handler=1
The attached file is a sanitizer blacklist file which documents this resolution, and implements the blacklisting (but not the environmental variable).
Nick, can we put this in contrib? I think that's the best way to deal with the special case of "clang users running tests under AddressSanitizer"