From: Arnaud Giersch Date: Sun, 10 Jun 2018 19:36:19 +0000 (+0200) Subject: Rename ASAN_EVAL to ASAN_ONLY, and kill ASAN_ASSERT. X-Git-Tag: v3.20~119 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/3a107fb48caa59bc8284aaf2f47a161132e39e9c?hp=804f52432ed93f41925a4dbe0db55ff1ca6bc9d1 Rename ASAN_EVAL to ASAN_ONLY, and kill ASAN_ASSERT. --- diff --git a/src/kernel/context/ContextBoost.cpp b/src/kernel/context/ContextBoost.cpp index e508c5646a..b75b44cc2e 100644 --- a/src/kernel/context/ContextBoost.cpp +++ b/src/kernel/context/ContextBoost.cpp @@ -75,7 +75,7 @@ BoostContext::BoostContext(std::function code, void_pfn_smxprocess_t cle #else void* stack = this->stack_; #endif - ASAN_EVAL(this->asan_stack_ = stack); + ASAN_ONLY(this->asan_stack_ = stack); #if BOOST_VERSION < 106100 this->fc_ = boost::context::make_fcontext(stack, smx_context_usable_stack_size, BoostContext::wrapper); #else @@ -107,7 +107,7 @@ void BoostContext::wrapper(BoostContext::arg_type arg) BoostContext* context = reinterpret_cast(arg); #else BoostContext* context = static_cast(arg.data)[1]; - ASAN_ASSERT(context->asan_ctx_ == static_cast(arg.data)[0]); + ASAN_ONLY(xbt_assert(context->asan_ctx_ == static_cast(arg.data)[0])); ASAN_FINISH_SWITCH(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_); static_cast(arg.data)[0]->fc_ = arg.fctx; #endif @@ -117,7 +117,7 @@ void BoostContext::wrapper(BoostContext::arg_type arg) } catch (StopRequest const&) { XBT_DEBUG("Caught a StopRequest"); } - ASAN_EVAL(context->asan_stop_ = true); + ASAN_ONLY(context->asan_stop_ = true); context->suspend(); } @@ -130,10 +130,10 @@ inline void BoostContext::swap(BoostContext* from, BoostContext* to) #else BoostContext* ctx[2] = {from, to}; void* fake_stack = nullptr; - ASAN_EVAL(to->asan_ctx_ = from); + 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); - ASAN_ASSERT(from->asan_ctx_ == static_cast(arg.data)[0]); + ASAN_ONLY(xbt_assert(from->asan_ctx_ == static_cast(arg.data)[0])); ASAN_FINISH_SWITCH(fake_stack, &from->asan_ctx_->asan_stack_, &from->asan_ctx_->asan_stack_size_); static_cast(arg.data)[0]->fc_ = arg.fctx; #endif diff --git a/src/kernel/context/ContextRaw.cpp b/src/kernel/context/ContextRaw.cpp index 1a80e46a68..7f006bc22d 100644 --- a/src/kernel/context/ContextRaw.cpp +++ b/src/kernel/context/ContextRaw.cpp @@ -237,9 +237,9 @@ RawContext::RawContext(std::function code, void_pfn_smxprocess_t cleanup if (has_code()) { this->stack_ = SIMIX_context_stack_new(); #if PTH_STACKGROWTH == -1 - ASAN_EVAL(this->asan_stack_ = static_cast(this->stack_) + smx_context_usable_stack_size); + ASAN_ONLY(this->asan_stack_ = static_cast(this->stack_) + smx_context_usable_stack_size); #else - ASAN_EVAL(this->asan_stack_ = this->stack_); + ASAN_ONLY(this->asan_stack_ = this->stack_); #endif this->stack_top_ = raw_makecontext(this->stack_, smx_context_usable_stack_size, RawContext::wrapper, this); } else { @@ -265,14 +265,14 @@ void RawContext::wrapper(void* arg) } catch (StopRequest const&) { XBT_DEBUG("Caught a StopRequest"); } - ASAN_EVAL(context->asan_stop_ = true); + ASAN_ONLY(context->asan_stop_ = true); context->suspend(); } inline void RawContext::swap(RawContext* from, RawContext* to) { void* fake_stack = nullptr; - ASAN_EVAL(to->asan_ctx_ = from); + 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_); ASAN_FINISH_SWITCH(fake_stack, &from->asan_ctx_->asan_stack_, &from->asan_ctx_->asan_stack_size_); diff --git a/src/kernel/context/ContextUnix.cpp b/src/kernel/context/ContextUnix.cpp index 4c509ba425..b4af204f3a 100644 --- a/src/kernel/context/ContextUnix.cpp +++ b/src/kernel/context/ContextUnix.cpp @@ -87,9 +87,9 @@ UContext::UContext(std::function code, void_pfn_smxprocess_t cleanup_fun this->uc_.uc_stack.ss_sp = sg_makecontext_stack_addr(this->stack_); this->uc_.uc_stack.ss_size = sg_makecontext_stack_size(smx_context_usable_stack_size); #if PTH_STACKGROWTH == -1 - ASAN_EVAL(this->asan_stack_ = static_cast(this->stack_) + smx_context_usable_stack_size); + ASAN_ONLY(this->asan_stack_ = static_cast(this->stack_) + smx_context_usable_stack_size); #else - ASAN_EVAL(this->asan_stack_ = this->stack_); + ASAN_ONLY(this->asan_stack_ = this->stack_); #endif UContext::make_ctx(&this->uc_, UContext::smx_ctx_sysv_wrapper, this); } else { @@ -125,7 +125,7 @@ void UContext::smx_ctx_sysv_wrapper(int i1, int i2) } catch (simgrid::kernel::context::Context::StopRequest const&) { XBT_DEBUG("Caught a StopRequest"); } - ASAN_EVAL(context->asan_stop_ = true); + ASAN_ONLY(context->asan_stop_ = true); context->suspend(); } @@ -144,7 +144,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_EVAL(to->asan_ctx_ = from); + 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_); ASAN_FINISH_SWITCH(fake_stack, &from->asan_ctx_->asan_stack_, &from->asan_ctx_->asan_stack_size_); diff --git a/src/kernel/context/context_private.hpp b/src/kernel/context/context_private.hpp index 6788e1b730..037ce012a5 100644 --- a/src/kernel/context/context_private.hpp +++ b/src/kernel/context/context_private.hpp @@ -10,14 +10,12 @@ #if HAVE_SANITIZE_ADDRESS_FIBER_SUPPORT #include -#define ASAN_ASSERT(...) xbt_assert(__VA_ARGS__) -#define ASAN_EVAL(expr) (expr) +#define ASAN_ONLY(expr) expr #define ASAN_START_SWITCH(fake_stack_save, bottom, size) __sanitizer_start_switch_fiber(fake_stack_save, bottom, size) #define ASAN_FINISH_SWITCH(fake_stack_save, bottom_old, size_old) \ __sanitizer_finish_switch_fiber(fake_stack_save, bottom_old, size_old) #else -#define ASAN_ASSERT(expr) (void)0 -#define ASAN_EVAL(expr) (void)0 +#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) #endif