debug: asan: Added leak suppression for SDL2 & X11
Added leak suppression, by implementing __lsan_default_suppressions function, for SDL2 and X11 library which are used by the SDL display driver. Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
This commit is contained in:
parent
a0d6289289
commit
3da873a0c0
|
@ -345,7 +345,7 @@
|
|||
/subsys/bluetooth/mesh/ @jhedberg @trond-snekvik @joerchan @Vudentz
|
||||
/subsys/cpp/ @pabigot @vanwinkeljan
|
||||
/subsys/debug/ @nashif
|
||||
/subsys/debug/asan.c @vanwinkeljan @aescolar
|
||||
/subsys/debug/asan_hacks.c @vanwinkeljan @aescolar
|
||||
/subsys/disk/disk_access_spi_sdhc.c @JunYangNXP
|
||||
/subsys/disk/disk_access_sdhc.h @JunYangNXP
|
||||
/subsys/disk/disk_access_usdhc.c @JunYangNXP
|
||||
|
|
|
@ -7,7 +7,7 @@ zephyr_sources_ifdef(
|
|||
|
||||
zephyr_sources_ifdef(
|
||||
CONFIG_ASAN
|
||||
asan.c
|
||||
asan_hacks.c
|
||||
)
|
||||
|
||||
add_subdirectory(tracing)
|
||||
|
|
|
@ -57,6 +57,20 @@ config ASAN
|
|||
This behavior can be changes by adding leak_check_at_exit=1 to the
|
||||
environment variable ASAN_OPTIONS.
|
||||
|
||||
if ASAN
|
||||
config ASAN_NOP_DLCLOSE
|
||||
bool "Override host OS dlclose() with a NOP"
|
||||
default y if HAS_SDL
|
||||
help
|
||||
Override host OS dlclose() with a NOP.
|
||||
|
||||
This NOP implementation is needed as workaround for a known limitation in
|
||||
LSAN (leak sanitizer) that if dlcose is called before performing the leak
|
||||
check, "<unknown module>" is reported in the stack traces during the leak
|
||||
check and these can not be suppressed, see
|
||||
https://github.com/google/sanitizers/issues/89 for more info.
|
||||
endif # ASAN
|
||||
|
||||
config UBSAN
|
||||
bool "Build with undefined behavior sanitizer"
|
||||
depends on ARCH_POSIX
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Jan Van Winkel <jan.van_winkel@dxplore.eu>
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
const char *__asan_default_options(void)
|
||||
{
|
||||
return
|
||||
#if defined(CONFIG_64BIT) && defined(__GNUC__) && !defined(__clang__)
|
||||
/* Running leak detection at exit could lead to a deadlock on
|
||||
* 64-bit boards if GCC is used.
|
||||
* https://github.com/zephyrproject-rtos/zephyr/issues/20122
|
||||
*/
|
||||
"leak_check_at_exit=0:"
|
||||
#endif
|
||||
"";
|
||||
}
|
41
subsys/debug/asan_hacks.c
Normal file
41
subsys/debug/asan_hacks.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Jan Van Winkel <jan.van_winkel@dxplore.eu>
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_64BIT) && defined(__GNUC__) && !defined(__clang__)
|
||||
const char *__asan_default_options(void)
|
||||
{
|
||||
/* Running leak detection at exit could lead to a deadlock on
|
||||
* 64-bit boards if GCC is used.
|
||||
* https://github.com/zephyrproject-rtos/zephyr/issues/20122
|
||||
*/
|
||||
return "leak_check_at_exit=0:";
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HAS_SDL
|
||||
const char *__lsan_default_suppressions(void)
|
||||
{
|
||||
/* The SDL2 library does not clean-up all it resources on exit,
|
||||
* as such suppress all memory leaks coming from libSDL2 and the
|
||||
* underlying X11 library
|
||||
*/
|
||||
return "leak:libX11\nleak:libSDL2\n";
|
||||
}
|
||||
#endif /* CONFIG_HAS_SDL */
|
||||
|
||||
#ifdef CONFIG_ASAN_NOP_DLCLOSE
|
||||
/* LSAN has a known limitation that if dlcose is called before performing the
|
||||
* leak check; "<unknown module>" is reported in the stack traces during the
|
||||
* leak check and these can not be suppressed, see
|
||||
* https://github.com/google/sanitizers/issues/89 for more info.
|
||||
*
|
||||
* A workaround for this is to implement a NOP version of dlclose.
|
||||
*/
|
||||
int dlclose(void *handler)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_ASAN_NOP_DLCLOSE */
|
Loading…
Reference in a new issue