debug: Disable "at exit" LSAN leak check
Disable "at exit" memory leak check by LSAN if building for a 64-bit target with GCC. This is need to fix a potential deadlock in GCCs libasan implementation. Fixes #20122 Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
This commit is contained in:
parent
3ac7c6fcbf
commit
4286cb830f
3 changed files with 28 additions and 0 deletions
|
@ -5,4 +5,9 @@ zephyr_sources_ifdef(
|
||||||
openocd.c
|
openocd.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
zephyr_sources_ifdef(
|
||||||
|
CONFIG_ASAN
|
||||||
|
asan.c
|
||||||
|
)
|
||||||
|
|
||||||
add_subdirectory(tracing)
|
add_subdirectory(tracing)
|
||||||
|
|
|
@ -52,6 +52,11 @@ config ASAN
|
||||||
recent-ish compiler with the ``-fsanitize=address`` command line option,
|
recent-ish compiler with the ``-fsanitize=address`` command line option,
|
||||||
and the libasan library.
|
and the libasan library.
|
||||||
|
|
||||||
|
Note that at exit leak detection is disabled for 64-bit boards when
|
||||||
|
GCC is used due to potential risk of a deadlock in libasan.
|
||||||
|
This behavior can be changes by adding leak_check_at_exit=1 to the
|
||||||
|
environment variable ASAN_OPTIONS.
|
||||||
|
|
||||||
config UBSAN
|
config UBSAN
|
||||||
bool "Build with undefined behavior sanitizer"
|
bool "Build with undefined behavior sanitizer"
|
||||||
depends on ARCH_POSIX
|
depends on ARCH_POSIX
|
||||||
|
|
18
subsys/debug/asan.c
Normal file
18
subsys/debug/asan.c
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
"";
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue