Certainly a false positive seen with s4u-exec-ptask and swapped contexts:
==
3408837==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7fbcf3ffe0f0 at pc 0x7fbcf83efc32 bp 0x7fbcf3ffe040 sp 0x7fbcf3ffe038
WRITE of size 8 at 0x7fbcf3ffe0f0 thread T0
#0 0x7fbcf83efc31 in _M_init_functor ../src/s4u/s4u_Activity.cpp:63
#1 0x7fbcf83efc31 in _M_init_functor /usr/include/c++/10/bits/std_function.h:208
#2 0x7fbcf83efc31 in function<simgrid::kernel::actor::simcall<simgrid::s4u::Activity::cancel()::<lambda()> >::<lambda()> > /usr/include/c++/10/bits/std_function.h:609
#3 0x7fbcf83efc31 in simcall<simgrid::s4u::Activity::cancel()::<lambda()> > ../include/simgrid/simix.hpp:60
#4 0x7fbcf83efc31 in simgrid::s4u::Activity::cancel() ../src/s4u/s4u_Activity.cpp:63
#5 0x55e051d23c53 in simgrid::s4u::Activity_T<simgrid::s4u::Exec>::cancel() ../include/simgrid/s4u/Activity.hpp:223
#6 0x55e051d23c53 in runner ../examples/cpp/exec-ptask/s4u-exec-ptask.cpp:61
#7 0x7fbcf84d9d51 in std::function<void ()>::operator()() const /usr/include/c++/10/bits/std_function.h:622
#8 0x7fbcf84d9d51 in simgrid::kernel::context::Context::operator()() const ../src/kernel/context/Context.hpp:65
#9 0x7fbcf84d9d51 in smx_ctx_wrapper ../src/kernel/context/ContextSwapped.cpp:51
Activity* Activity::cancel()
{
- kernel::actor::simcall([this] { pimpl_->cancel(); });
+ kernel::actor::simcall([this] {
+ XBT_HERE();
+ pimpl_->cancel();
+ });
complete(State::CANCELED);
return this;
}