The protection in set_maestro was failing to detect between the real
maestro and the working threads of the parmal. This is now fixed
according to helgrind.
Also, refactor things a bit by moving this set_maestro call directly
into the SwappedCtx constructor. Much less of a shotgun surgery :)
- set_maestro(this); // save maestro for run_all()
#if BOOST_VERSION < 105600
this->fc_ = new boost::context::fcontext_t();
#endif
#if BOOST_VERSION < 105600
this->fc_ = new boost::context::fcontext_t();
#endif
#endif
this->stack_top_ = raw_makecontext(get_stack(), smx_context_usable_stack_size, RawContext::wrapper, this);
} else {
#endif
this->stack_top_ = raw_makecontext(get_stack(), smx_context_usable_stack_size, RawContext::wrapper, this);
} else {
- set_maestro(this); // save maestro for run_all()
if (MC_is_active())
MC_ignore_heap(&stack_top_, sizeof(stack_top_));
}
if (MC_is_active())
MC_ignore_heap(&stack_top_, sizeof(stack_top_));
}
SwappedContextFactory* factory)
: Context(std::move(code), cleanup_func, process), factory_(factory)
{
SwappedContextFactory* factory)
: Context(std::move(code), cleanup_func, process), factory_(factory)
{
+ // Save maestro (=context created first) in preparation for run_all
+ if (factory_->workers_context_[0] == nullptr)
+ factory_->workers_context_[0] = this;
+
if (has_code()) {
if (smx_context_guard_size > 0 && not MC_is_active()) {
if (has_code()) {
if (smx_context_guard_size > 0 && not MC_is_active()) {
-void SwappedContext::set_maestro(SwappedContext* ctx)
-{
- if (factory_->threads_working_ == 0) // Don't save the soul of minions, only the one of maestro
- factory_->workers_context_[0] = ctx;
-}
-
void* SwappedContext::get_stack()
{
return stack_;
void* SwappedContext::get_stack()
{
return stack_;
virtual void swap_into(SwappedContext* to) = 0; // Defined in Raw, Boost and UContext subclasses
virtual void swap_into(SwappedContext* to) = 0; // Defined in Raw, Boost and UContext subclasses
- void set_maestro(SwappedContext* ctx);
void* get_stack();
// FIXME: Killme
void* get_stack();
// FIXME: Killme
ASAN_ONLY(this->asan_stack_ = get_stack());
#endif
UContext::make_ctx(&this->uc_, UContext::smx_ctx_sysv_wrapper, this);
ASAN_ONLY(this->asan_stack_ = get_stack());
#endif
UContext::make_ctx(&this->uc_, UContext::smx_ctx_sysv_wrapper, this);
- } else {
- set_maestro(this); // save maestro for run_all()