Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Factorize some of the ASAN_ONLY code.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 21 Jan 2019 21:45:14 +0000 (22:45 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 21 Jan 2019 22:05:00 +0000 (23:05 +0100)
Also make asan_* members public to be visible from smx_ctx_wrapper
(ContextUnix,cpp).

src/kernel/context/ContextBoost.cpp
src/kernel/context/ContextBoost.hpp
src/kernel/context/ContextRaw.cpp
src/kernel/context/ContextRaw.hpp
src/kernel/context/ContextSwapped.cpp
src/kernel/context/ContextSwapped.hpp
src/kernel/context/ContextUnix.cpp
src/kernel/context/ContextUnix.hpp

index e229a5c..1bddeb1 100644 (file)
@@ -37,7 +37,6 @@ BoostContext::BoostContext(std::function<void()> code, void_pfn_smxprocess_t cle
 #else
     void* stack = get_stack();
 #endif
-    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
index 239bcfa..12bca09 100644 (file)
@@ -49,12 +49,6 @@ private:
   boost::context::detail::fcontext_t fc_;
   typedef boost::context::detail::transfer_t arg_type;
 #endif
-#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
-  const void* asan_stack_ = nullptr;
-  size_t asan_stack_size_ = 0;
-  BoostContext* asan_ctx_ = nullptr;
-  bool asan_stop_         = false;
-#endif
 
   static void wrapper(arg_type arg);
 };
index ffffc65..c7a0a1c 100644 (file)
@@ -199,11 +199,6 @@ RawContext::RawContext(std::function<void()> code, void_pfn_smxprocess_t cleanup
     : SwappedContext(std::move(code), cleanup, actor, factory)
 {
    if (has_code()) {
-#if PTH_STACKGROWTH == -1
-     ASAN_ONLY(this->asan_stack_ = static_cast<char*>(get_stack()) + smx_context_usable_stack_size);
-#else
-     ASAN_ONLY(this->asan_stack_ = get_stack());
-#endif
      this->stack_top_ = raw_makecontext(get_stack(), smx_context_usable_stack_size, RawContext::wrapper, this);
    } else {
      if (MC_is_active())
index 1ddb3b5..ab3967b 100644 (file)
@@ -35,13 +35,6 @@ private:
   /** pointer to top the stack stack */
   void* stack_top_ = nullptr;
 
-#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
-  const void* asan_stack_ = nullptr;
-  size_t asan_stack_size_ = 0;
-  RawContext* asan_ctx_   = nullptr;
-  bool asan_stop_         = false;
-#endif
-
   static void wrapper(void* arg);
 };
 
index 3c89743..2682e62 100644 (file)
@@ -98,6 +98,11 @@ SwappedContext::SwappedContext(std::function<void()> code, void_pfn_smxprocess_t
       this->stack_ = xbt_malloc0(smx_context_stack_size);
     }
 
+#if PTH_STACKGROWTH == -1
+    ASAN_ONLY(this->asan_stack_ = static_cast<char*>(this->stack_) + smx_context_usable_stack_size);
+#else
+    ASAN_ONLY(this->asan_stack_ = this->stack_);
+#endif
 #if HAVE_VALGRIND_H
     unsigned int valgrind_stack_id =
         VALGRIND_STACK_REGISTER(this->stack_, (char*)this->stack_ + smx_context_stack_size);
index 286211b..aba97d5 100644 (file)
@@ -49,6 +49,13 @@ public:
 
   static thread_local uintptr_t worker_id_;
 
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+  const void* asan_stack_   = nullptr;
+  size_t asan_stack_size_   = 0;
+  SwappedContext* asan_ctx_ = nullptr;
+  bool asan_stop_           = false;
+#endif
+
 private:
   void* stack_ = nullptr;                /* the thread stack */
   SwappedContextFactory* const factory_; // for sequential and parallel run_all()
index 3042e2f..92d9271 100644 (file)
@@ -74,11 +74,6 @@ UContext::UContext(std::function<void()> code, void_pfn_smxprocess_t cleanup_fun
     this->uc_.uc_link = nullptr;
     this->uc_.uc_stack.ss_sp   = sg_makecontext_stack_addr(get_stack());
     this->uc_.uc_stack.ss_size = sg_makecontext_stack_size(smx_context_usable_stack_size);
-#if PTH_STACKGROWTH == -1
-    ASAN_ONLY(this->asan_stack_ = static_cast<char*>(get_stack()) + smx_context_usable_stack_size);
-#else
-    ASAN_ONLY(this->asan_stack_ = get_stack());
-#endif
     // Makecontext expects integer arguments; we want to pass a pointer.
     // This context address is decomposed into a serie of integers, which are passed as arguments to makecontext.
 
index 4df2375..d136c5a 100644 (file)
@@ -32,13 +32,6 @@ public:
 
 private:
   ucontext_t uc_;         /* the ucontext that executes the code */
-
-#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
-  const void* asan_stack_ = nullptr;
-  size_t asan_stack_size_ = 0;
-  UContext* asan_ctx_     = nullptr;
-  bool asan_stop_         = false;
-#endif
 };
 
 class UContextFactory : public SwappedContextFactory {