- Context::stop();
- /* We must cut the actor execution using an exception to properly free the C++ RAII variables */
- throw ForcefulKillException();
+ // Depending on the stack direction, its bottom (that make_fcontext needs) may be the lower or higher end
+#if PTH_STACKGROWTH == 1
+ return stack_;
+#else
+ return stack_ + get_actor()->get_stacksize();
+#endif
+}
+
+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
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+ __tsan_switch_to_fiber(to->tsan_fiber_, 0);
+#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