Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Define and use SwappedContext::verify_previous_context().
[simgrid.git] / src / kernel / context / ContextSwapped.hpp
index c495b34..cabea51 100644 (file)
@@ -57,6 +57,10 @@ public:
   bool asan_stop_           = false;
 #endif
 
+protected:
+  // With ASan, after a context switch, check that the originating context is the expected one (see BoostContext)
+  void verify_previous_context(const SwappedContext* context) const;
+
 private:
   static thread_local SwappedContext* worker_context_;
 
@@ -68,6 +72,13 @@ private:
 #endif
 };
 
+inline void SwappedContext::verify_previous_context(XBT_ATTRIB_UNUSED const SwappedContext* context) const
+{
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+  xbt_assert(this->asan_ctx_ == context);
+#endif
+}
+
 } // namespace context
 } // namespace kernel
 } // namespace simgrid