Tests: Improve the sanitizer options handling.

Previous code was using the 'nuclear' SAN weapon `exitcode=0`, which
essentially makes testing ignore all sanitizer errors.

This commit removes this option, and instead uses the suppression
list from Blender source repository (`tools/config/analysis/lsan.supp`)
for the leak sanitizer.

It also enables the `allocator_may_return_null` for the address sanitizer.
This should only be needed for one test (the `guardedalloc` one), but for
now it is simpler to define it for all tests. This can be refined at a
later time.

Pull Request: https://projects.blender.org/blender/blender/pulls/116635
This commit is contained in:
Bastien Montagne 2024-01-09 12:22:38 +01:00 committed by Gitea
parent 0d60bf14f6
commit f23ee504d0
1 changed files with 1 additions and 6 deletions

View File

@ -26,14 +26,9 @@ function(blender_test_set_envvars testname envvars_list)
if(NOT CMAKE_BUILD_TYPE MATCHES "Release")
if(WITH_COMPILER_ASAN)
# Don't fail tests on leaks since these often happen in external libraries that we can't fix.
# FIXME This is a 'nuke solution', no xSAN errors will ever fail tests. Needs more refined handling,
# see https://projects.blender.org/blender/blender/pulls/116635 .
set(_lsan_options "LSAN_OPTIONS=exitcode=0")
set(_lsan_options "LSAN_OPTIONS=print_suppressions=false:suppressions=${CMAKE_SOURCE_DIR}/tools/config/analysis/lsan.supp")
# FIXME That `allocator_may_return_null=true` ASAN option is only needed for the `guardedalloc` test,
# would be nice to allow tests definition to pass extra envvars better.
# NOTE: This is needed for Mac builds currently, on Linux the `exitcode=0` option passed above to LSAN
# also seems to silence reports from ASAN.
set(_asan_options "ASAN_OPTIONS=allocator_may_return_null=true")
if(DEFINED ENV{LSAN_OPTIONS})
set(_lsan_options "${_lsan_options}:$ENV{LSAN_OPTIONS}")