From 8deab3c165fab198141857c815ccf585eb8d1cf1 Mon Sep 17 00:00:00 2001 From: Douglas Katzman Date: Fri, 4 Aug 2017 08:56:51 -0400 Subject: [PATCH] Workaround spurious complaints by ASAN and MSAN. ASAN says that gencgc reads wild pointers to the stack. Obviously. --- src/runtime/gencgc.c | 8 +++++++- src/runtime/linux-os.c | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/runtime/gencgc.c b/src/runtime/gencgc.c index 20c3364a4..ea7f8fe5f 100644 --- a/src/runtime/gencgc.c +++ b/src/runtime/gencgc.c @@ -3168,9 +3168,15 @@ move_pinned_pages_to_newspace() } } +#if defined(__GNUC__) && defined(ADDRESS_SANITIZER) +#define NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) +#else +#define NO_SANITIZE_ADDRESS +#endif + /* Garbage collect a generation. If raise is 0 then the remains of the * generation are not raised to the next generation. */ -static void +static void NO_SANITIZE_ADDRESS garbage_collect_generation(generation_index_t generation, int raise) { page_index_t i; diff --git a/src/runtime/linux-os.c b/src/runtime/linux-os.c index 53531def8..e3307cd2a 100644 --- a/src/runtime/linux-os.c +++ b/src/runtime/linux-os.c @@ -442,7 +442,12 @@ os_install_interrupt_handlers(void) char * os_get_runtime_executable_path(int external) { - char path[PATH_MAX + 1]; + /* XXX: zero-init here is due to an apparent false positive with MSAN. + Everyone who's looked at this agrees that readlink() null-terminates + the array, or else it's not read at all if readlink() fails. + The sanitizer complaint actually occurs in copied_string(). + It says "WARNING: MemorySanitizer: use-of-uninitialized-value" */ + char path[PATH_MAX + 1] = {0}; int size; size = readlink("/proc/self/exe", path, sizeof(path)-1); -- 2.11.4.GIT