Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rename ASAN_EVAL to ASAN_ONLY, and kill ASAN_ASSERT.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 10 Jun 2018 19:36:19 +0000 (21:36 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 10 Jun 2018 19:36:19 +0000 (21:36 +0200)
src/kernel/context/ContextBoost.cpp
src/kernel/context/ContextRaw.cpp
src/kernel/context/ContextUnix.cpp
src/kernel/context/context_private.hpp

index e508c56..b75b44c 100644 (file)
@@ -75,7 +75,7 @@ BoostContext::BoostContext(std::function<void()> code, void_pfn_smxprocess_t cle
 #else
     void* stack = this->stack_;
 #endif
 #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
 #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<BoostContext*>(arg);
 #else
   BoostContext* context = static_cast<BoostContext**>(arg.data)[1];
   BoostContext* context = reinterpret_cast<BoostContext*>(arg);
 #else
   BoostContext* context = static_cast<BoostContext**>(arg.data)[1];
-  ASAN_ASSERT(context->asan_ctx_ == static_cast<BoostContext**>(arg.data)[0]);
+  ASAN_ONLY(xbt_assert(context->asan_ctx_ == static_cast<BoostContext**>(arg.data)[0]));
   ASAN_FINISH_SWITCH(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_);
   static_cast<BoostContext**>(arg.data)[0]->fc_ = arg.fctx;
 #endif
   ASAN_FINISH_SWITCH(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_);
   static_cast<BoostContext**>(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");
   }
   } catch (StopRequest const&) {
     XBT_DEBUG("Caught a StopRequest");
   }
-  ASAN_EVAL(context->asan_stop_ = true);
+  ASAN_ONLY(context->asan_stop_ = true);
   context->suspend();
 }
 
   context->suspend();
 }
 
@@ -130,10 +130,10 @@ inline void BoostContext::swap(BoostContext* from, BoostContext* to)
 #else
   BoostContext* ctx[2] = {from, to};
   void* fake_stack     = nullptr;
 #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_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<BoostContext**>(arg.data)[0]);
+  ASAN_ONLY(xbt_assert(from->asan_ctx_ == static_cast<BoostContext**>(arg.data)[0]));
   ASAN_FINISH_SWITCH(fake_stack, &from->asan_ctx_->asan_stack_, &from->asan_ctx_->asan_stack_size_);
   static_cast<BoostContext**>(arg.data)[0]->fc_ = arg.fctx;
 #endif
   ASAN_FINISH_SWITCH(fake_stack, &from->asan_ctx_->asan_stack_, &from->asan_ctx_->asan_stack_size_);
   static_cast<BoostContext**>(arg.data)[0]->fc_ = arg.fctx;
 #endif
index 1a80e46..7f006bc 100644 (file)
@@ -237,9 +237,9 @@ RawContext::RawContext(std::function<void()> code, void_pfn_smxprocess_t cleanup
    if (has_code()) {
      this->stack_ = SIMIX_context_stack_new();
 #if PTH_STACKGROWTH == -1
    if (has_code()) {
      this->stack_ = SIMIX_context_stack_new();
 #if PTH_STACKGROWTH == -1
-     ASAN_EVAL(this->asan_stack_ = static_cast<char*>(this->stack_) + smx_context_usable_stack_size);
+     ASAN_ONLY(this->asan_stack_ = static_cast<char*>(this->stack_) + smx_context_usable_stack_size);
 #else
 #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 {
 #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");
   }
   } 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;
   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_);
   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_);
index 4c509ba..b4af204 100644 (file)
@@ -87,9 +87,9 @@ UContext::UContext(std::function<void()> 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
     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<char*>(this->stack_) + smx_context_usable_stack_size);
+    ASAN_ONLY(this->asan_stack_ = static_cast<char*>(this->stack_) + smx_context_usable_stack_size);
 #else
 #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 {
 #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");
   }
   } 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();
 }
 
   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;
 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_);
   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_);
index 6788e1b..037ce01 100644 (file)
 
 #if HAVE_SANITIZE_ADDRESS_FIBER_SUPPORT
 #include <sanitizer/asan_interface.h>
 
 #if HAVE_SANITIZE_ADDRESS_FIBER_SUPPORT
 #include <sanitizer/asan_interface.h>
-#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_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
 #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