From 80c95bbdf359c54abaeacdbcc070b7b5d3b25b6a Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Mon, 20 Dec 2021 18:13:27 -0800 Subject: [PATCH] [sanitizer] Fix compress_stack_depot.cpp test on Darwin All platforms which can start the thread should stop it as well. --- .../sanitizer_common_libcdep.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp index a703db48d4c3..c4cc0e45193e 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp @@ -22,7 +22,6 @@ namespace __sanitizer { #if (SANITIZER_LINUX || SANITIZER_NETBSD) && !SANITIZER_GO // Weak default implementation for when sanitizer_stackdepot is not linked in. SANITIZER_WEAK_ATTRIBUTE StackDepotStats StackDepotGetStats() { return {}; } -SANITIZER_WEAK_ATTRIBUTE void StackDepotStopBackgroundThread() {} void *BackgroundThread(void *arg) { VPrintf(1, "%s: Started BackgroundThread\n", SanitizerToolName); @@ -200,13 +199,22 @@ void ProtectGap(uptr addr, uptr size, uptr zero_base_shadow_start, #endif // !SANITIZER_FUCHSIA +#if !SANITIZER_WINDOWS && !SANITIZER_GO +// Weak default implementation for when sanitizer_stackdepot is not linked in. +SANITIZER_WEAK_ATTRIBUTE void StackDepotStopBackgroundThread() {} +static void StopStackDepotBackgroundThread() { + StackDepotStopBackgroundThread(); +} +#else +// SANITIZER_WEAK_ATTRIBUTE is unsupported. +static void StopStackDepotBackgroundThread() {} +#endif + } // namespace __sanitizer SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_sandbox_on_notify, __sanitizer_sandbox_arguments *args) { -#if (SANITIZER_LINUX || SANITIZER_NETBSD) && !SANITIZER_GO - __sanitizer::StackDepotStopBackgroundThread(); -#endif + __sanitizer::StopStackDepotBackgroundThread(); __sanitizer::PlatformPrepareForSandboxing(args); if (__sanitizer::sandboxing_callback) __sanitizer::sandboxing_callback();