From 5d6dd7f0a4a1dd08189c44dfbb20c7adb5ceb9c5 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Sun, 10 Jun 2018 21:37:29 +0200 Subject: [PATCH 1/1] Declare fake_stack only with ASan. --- src/kernel/context/ContextBoost.cpp | 2 +- src/kernel/context/ContextRaw.cpp | 2 +- src/kernel/context/ContextUnix.cpp | 2 +- src/kernel/context/context_private.hpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/kernel/context/ContextBoost.cpp b/src/kernel/context/ContextBoost.cpp index b75b44cc2e..567329504a 100644 --- a/src/kernel/context/ContextBoost.cpp +++ b/src/kernel/context/ContextBoost.cpp @@ -129,7 +129,7 @@ inline void BoostContext::swap(BoostContext* from, BoostContext* to) boost::context::jump_fcontext(&from->fc_, to->fc_, reinterpret_cast(to)); #else BoostContext* ctx[2] = {from, to}; - void* fake_stack = nullptr; + ASAN_ONLY(void* fake_stack = nullptr); ASAN_ONLY(to->asan_ctx_ = from); ASAN_START_SWITCH(from->asan_stop_ ? nullptr : &fake_stack, to->asan_stack_, to->asan_stack_size_); boost::context::detail::transfer_t arg = boost::context::detail::jump_fcontext(to->fc_, ctx); diff --git a/src/kernel/context/ContextRaw.cpp b/src/kernel/context/ContextRaw.cpp index 7f006bc22d..fbaec9ba82 100644 --- a/src/kernel/context/ContextRaw.cpp +++ b/src/kernel/context/ContextRaw.cpp @@ -271,7 +271,7 @@ void RawContext::wrapper(void* arg) inline void RawContext::swap(RawContext* from, RawContext* to) { - void* fake_stack = nullptr; + ASAN_ONLY(void* fake_stack = nullptr); ASAN_ONLY(to->asan_ctx_ = from); ASAN_START_SWITCH(from->asan_stop_ ? nullptr : &fake_stack, to->asan_stack_, to->asan_stack_size_); raw_swapcontext(&from->stack_top_, to->stack_top_); diff --git a/src/kernel/context/ContextUnix.cpp b/src/kernel/context/ContextUnix.cpp index b4af204f3a..af76c2ccbe 100644 --- a/src/kernel/context/ContextUnix.cpp +++ b/src/kernel/context/ContextUnix.cpp @@ -143,7 +143,7 @@ void UContext::make_ctx(ucontext_t* ucp, void (*func)(int, int), UContext* arg) inline void UContext::swap(UContext* from, UContext* to) { - void* fake_stack = nullptr; + ASAN_ONLY(void* fake_stack = nullptr); ASAN_ONLY(to->asan_ctx_ = from); ASAN_START_SWITCH(from->asan_stop_ ? nullptr : &fake_stack, to->asan_stack_, to->asan_stack_size_); swapcontext(&from->uc_, &to->uc_); diff --git a/src/kernel/context/context_private.hpp b/src/kernel/context/context_private.hpp index 037ce012a5..756aba9838 100644 --- a/src/kernel/context/context_private.hpp +++ b/src/kernel/context/context_private.hpp @@ -17,7 +17,7 @@ #else #define ASAN_ONLY(expr) (void)0 #define ASAN_START_SWITCH(fake_stack_save, bottom, size) (void)0 -#define ASAN_FINISH_SWITCH(fake_stack_save, bottom_old, size_old) (void)(fake_stack_save) +#define ASAN_FINISH_SWITCH(fake_stack_save, bottom_old, size_old) (void)0 #endif #endif -- 2.20.1