/* if the user provided a function for the process then use it, otherwise it is the context for maestro */
if (has_code()) {
- /* We need to pass the bottom of the stack to make_fcontext,
- depending on the stack direction it may be the lower or higher address: */
-#if PTH_STACKGROWTH == -1
- unsigned char* stack = get_stack() + smx_context_stack_size;
-#else
- unsigned char* stack = get_stack();
-#endif
#if BOOST_VERSION < 106100
- this->fc_ = boost::context::make_fcontext(stack, smx_context_stack_size, BoostContext::wrapper);
+ this->fc_ = boost::context::make_fcontext(get_stack_bottom(), smx_context_stack_size, BoostContext::wrapper);
#else
- this->fc_ = boost::context::detail::make_fcontext(stack, smx_context_stack_size, BoostContext::wrapper);
+ this->fc_ =
+ boost::context::detail::make_fcontext(get_stack_bottom(), smx_context_stack_size, BoostContext::wrapper);
#endif
}
}
if (has_code()) {
xbt_assert((smx_context_stack_size & 0xf) == 0, "smx_context_stack_size should be multiple of 16");
if (smx_context_guard_size > 0 && not MC_is_active()) {
-#if !defined(PTH_STACKGROWTH) || (PTH_STACKGROWTH != -1)
+#if PTH_STACKGROWTH != -1
xbt_die(
"Stack overflow protection is known to be broken on your system: you stacks grow upwards (or detection is "
"broken). "
this->stack_ = static_cast<unsigned char*>(xbt_malloc0(smx_context_stack_size));
}
-#if PTH_STACKGROWTH == -1
- ASAN_ONLY(this->asan_stack_ = this->stack_ + smx_context_stack_size);
-#else
- ASAN_ONLY(this->asan_stack_ = this->stack_);
-#endif
#if HAVE_VALGRIND_H
if (RUNNING_ON_VALGRIND)
this->valgrind_stack_id_ = VALGRIND_STACK_REGISTER(this->stack_, this->stack_ + smx_context_stack_size);
+#endif
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+ this->asan_stack_ = get_stack_bottom();
#endif
}
}
xbt_free(stack_);
}
-unsigned char* SwappedContext::get_stack()
-{
- return stack_;
-}
-
void SwappedContext::stop()
{
Context::stop();
virtual void swap_into(SwappedContext* to) = 0; // Defined in Raw, Boost and UContext subclasses
- unsigned char* get_stack();
+ 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;