include src/kernel/context/ContextThread.hpp
include src/kernel/context/ContextUnix.cpp
include src/kernel/context/ContextUnix.hpp
-include src/kernel/context/context_private.hpp
include src/kernel/future.cpp
include src/kernel/lmm/fair_bottleneck.cpp
include src/kernel/lmm/maxmin.cpp
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "ContextBoost.hpp"
-#include "context_private.hpp"
#include "simgrid/Exception.hpp"
#include "src/simix/smx_private.hpp"
smx_ctx_wrapper(context);
}
-void BoostContext::swap_into(SwappedContext* to_)
+void BoostContext::swap_into_for_real(SwappedContext* to_)
{
BoostContext* to = static_cast<BoostContext*>(to_);
#if BOOST_VERSION < 106100
boost::context::jump_fcontext(&this->fc_, to->fc_, reinterpret_cast<intptr_t>(to));
#else
BoostContext* ctx[2] = {this, to};
- ASAN_ONLY(void* fake_stack = nullptr);
- ASAN_ONLY(to->asan_ctx_ = this);
- ASAN_START_SWITCH(this->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);
this->verify_previous_context(static_cast<BoostContext**>(arg.data)[0]);
- ASAN_FINISH_SWITCH(fake_stack, &this->asan_ctx_->asan_stack_, &this->asan_ctx_->asan_stack_size_);
static_cast<BoostContext**>(arg.data)[0]->fc_ = arg.fctx;
#endif
}
public:
BoostContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory);
- void swap_into(SwappedContext* to) override;
-
private:
#if BOOST_VERSION < 106100
boost::context::fcontext_t fc_;
#endif
XBT_ATTRIB_NORETURN static void wrapper(arg_type arg);
+
+ void swap_into_for_real(SwappedContext* to) override;
};
class BoostContextFactory : public SwappedContextFactory {
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "ContextRaw.hpp"
-#include "context_private.hpp"
#include "mc/mc.h"
#include "simgrid/Exception.hpp"
#include "src/simix/smx_private.hpp"
}
}
-void RawContext::swap_into(SwappedContext* to_)
+void RawContext::swap_into_for_real(SwappedContext* to_)
{
const RawContext* to = static_cast<RawContext*>(to_);
- ASAN_ONLY(void* fake_stack = nullptr);
- ASAN_ONLY(to_->asan_ctx_ = this);
- ASAN_START_SWITCH(this->asan_stop_ ? nullptr : &fake_stack, to_->asan_stack_, to_->asan_stack_size_);
raw_swapcontext(&this->stack_top_, to->stack_top_);
- ASAN_FINISH_SWITCH(fake_stack, &this->asan_ctx_->asan_stack_, &this->asan_ctx_->asan_stack_size_);
}
ContextFactory* raw_factory()
public:
RawContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory);
- void swap_into(SwappedContext* to) override;
-
private:
/** pointer to top the stack stack */
void* stack_top_ = nullptr;
+
+ void swap_into_for_real(SwappedContext* to) override;
};
class RawContextFactory : public SwappedContextFactory {
#include "simgrid/modelchecker.h"
#include "src/internal_config.h"
#include "src/kernel/actor/ActorImpl.hpp"
-#include "src/kernel/context/context_private.hpp"
#include "src/simix/smx_private.hpp"
#include "xbt/parmap.hpp"
#if HAVE_VALGRIND_H
#include <valgrind/valgrind.h>
#endif
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+#include <sanitizer/asan_interface.h>
+#endif
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
throw ForcefulKillException();
}
+void SwappedContext::swap_into(SwappedContext* to)
+{
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+ void* fake_stack = nullptr;
+ to->asan_ctx_ = this;
+ __sanitizer_start_switch_fiber(this->asan_stop_ ? nullptr : &fake_stack, to->asan_stack_, to->asan_stack_size_);
+#endif
+
+ swap_into_for_real(to);
+
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+ __sanitizer_finish_switch_fiber(fake_stack, &this->asan_ctx_->asan_stack_, &this->asan_ctx_->asan_stack_size_);
+#endif
+}
+
/** Maestro wants to run all ready actors */
void SwappedContextFactory::run_all()
{
#ifndef SIMGRID_KERNEL_CONTEXT_SWAPPED_CONTEXT_HPP
#define SIMGRID_KERNEL_CONTEXT_SWAPPED_CONTEXT_HPP
+#include "src/internal_config.h" // HAVE_SANITIZER_*
#include "src/kernel/context/Context.hpp"
#include <memory>
virtual void resume();
XBT_ATTRIB_NORETURN void stop() override;
- virtual void swap_into(SwappedContext* to) = 0; // Defined in Raw, Boost and UContext subclasses
+ void swap_into(SwappedContext* to);
unsigned char* get_stack() const { return stack_; }
// Return the address for the bottom of the stack. Depending on the stack direction it may be the lower or higher
// address
unsigned char* get_stack_bottom() const { return PTH_STACKGROWTH == -1 ? stack_ + smx_context_stack_size : stack_; }
-#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
-
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;
#if HAVE_VALGRIND_H
unsigned int valgrind_stack_id_;
#endif
+#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
+
+ virtual void swap_into_for_real(SwappedContext* to) = 0; // Defined in Raw, Boost and UContext subclasses
};
inline void SwappedContext::verify_previous_context(XBT_ATTRIB_UNUSED const SwappedContext* context) const
/* \file UContext.cpp Context switching with ucontexts from System V */
-#include "context_private.hpp"
-
#include "mc/mc.h"
#include "simgrid/Exception.hpp"
#include "src/kernel/actor/ActorImpl.hpp"
}
}
-void UContext::swap_into(SwappedContext* to_)
+void UContext::swap_into_for_real(SwappedContext* to_)
{
const UContext* to = static_cast<UContext*>(to_);
- ASAN_ONLY(void* fake_stack = nullptr);
- ASAN_ONLY(to_->asan_ctx_ = this);
- ASAN_START_SWITCH(this->asan_stop_ ? nullptr : &fake_stack, to_->asan_stack_, to_->asan_stack_size_);
swapcontext(&this->uc_, &to->uc_);
- ASAN_FINISH_SWITCH(fake_stack, &this->asan_ctx_->asan_stack_, &this->asan_ctx_->asan_stack_size_);
}
public:
UContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory);
- void swap_into(SwappedContext* to) override;
-
private:
ucontext_t uc_; /* the ucontext that executes the code */
+
+ void swap_into_for_real(SwappedContext* to) override;
};
class UContextFactory : public SwappedContextFactory {
+++ /dev/null
-/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved. */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#ifndef SIMGRID_KERNEL_CONTEXT_PRIVATE_HPP
-#define SIMGRID_KERNEL_CONTEXT_PRIVATE_HPP
-
-#include "src/internal_config.h"
-
-#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
-#include <sanitizer/asan_interface.h>
-#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_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)0
-#endif
-
-#endif
src/kernel/future.cpp
src/simix/libsmx.cpp
src/simix/smx_context.cpp
- src/kernel/context/context_private.hpp
src/kernel/context/Context.cpp
src/kernel/context/Context.hpp
src/kernel/context/ContextRaw.cpp