File tree Expand file tree Collapse file tree 5 files changed +57
-20
lines changed Expand file tree Collapse file tree 5 files changed +57
-20
lines changed Original file line number Diff line number Diff line change 345345/subsys /bluetooth /mesh / @ jhedberg @ trond-snekvik @ joerchan @ Vudentz
346346/subsys /cpp / @ pabigot @ vanwinkeljan
347347/subsys /debug / @ nashif
348- /subsys /debug /asan.c @ vanwinkeljan @ aescolar
348+ /subsys /debug /asan_hacks.c @ vanwinkeljan @ aescolar
349349/subsys /disk /disk_access_spi_sdhc.c @ JunYangNXP
350350/subsys /disk /disk_access_sdhc.h @ JunYangNXP
351351/subsys /disk /disk_access_usdhc.c @ JunYangNXP
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ zephyr_sources_ifdef(
77
88zephyr_sources_ifdef(
99 CONFIG_ASAN
10- asan .c
10+ asan_hacks .c
1111 )
1212
1313add_subdirectory (tracing)
Original file line number Diff line number Diff line change @@ -57,6 +57,20 @@ config ASAN
5757 This behavior can be changes by adding leak_check_at_exit=1 to the
5858 environment variable ASAN_OPTIONS.
5959
60+ if ASAN
61+ config ASAN_NOP_DLCLOSE
62+ bool "Override host OS dlclose() with a NOP"
63+ default y if HAS_SDL
64+ help
65+ Override host OS dlclose() with a NOP.
66+
67+ This NOP implementation is needed as workaround for a known limitation in
68+ LSAN (leak sanitizer) that if dlcose is called before performing the leak
69+ check, "<unknown module>" is reported in the stack traces during the leak
70+ check and these can not be suppressed, see
71+ https://github.com/google/sanitizers/issues/89 for more info.
72+ endif # ASAN
73+
6074config UBSAN
6175 bool "Build with undefined behavior sanitizer"
6276 depends on ARCH_POSIX
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2019 Jan Van Winkel <[email protected] > 3+ *
4+ * SPDX-License-Identifier: Apache-2.0
5+ */
6+
7+ #if defined(CONFIG_64BIT ) && defined(__GNUC__ ) && !defined(__clang__ )
8+ const char * __asan_default_options (void )
9+ {
10+ /* Running leak detection at exit could lead to a deadlock on
11+ * 64-bit boards if GCC is used.
12+ * https://github.com/zephyrproject-rtos/zephyr/issues/20122
13+ */
14+ return "leak_check_at_exit=0:" ;
15+ }
16+ #endif
17+
18+ #ifdef CONFIG_HAS_SDL
19+ const char * __lsan_default_suppressions (void )
20+ {
21+ /* The SDL2 library does not clean-up all it resources on exit,
22+ * as such suppress all memory leaks coming from libSDL2 and the
23+ * underlying X11 library
24+ */
25+ return "leak:libX11\nleak:libSDL2\n" ;
26+ }
27+ #endif /* CONFIG_HAS_SDL */
28+
29+ #ifdef CONFIG_ASAN_NOP_DLCLOSE
30+ /* LSAN has a known limitation that if dlcose is called before performing the
31+ * leak check; "<unknown module>" is reported in the stack traces during the
32+ * leak check and these can not be suppressed, see
33+ * https://github.com/google/sanitizers/issues/89 for more info.
34+ *
35+ * A workaround for this is to implement a NOP version of dlclose.
36+ */
37+ int dlclose (void * handler )
38+ {
39+ return 0 ;
40+ }
41+ #endif /* CONFIG_ASAN_NOP_DLCLOSE */
You can’t perform that action at this time.
0 commit comments