Commit 1899b17f authored by Dominik Charousset's avatar Dominik Charousset

Implement regression test for #1306

parent 9d5165d6
......@@ -9,6 +9,7 @@
#include "core-test.hpp"
using namespace caf;
using namespace std::literals;
namespace {
......@@ -170,3 +171,25 @@ SCENARIO("response promises allow delegation") {
}
END_FIXTURE_SCOPE()
CAF_TEST("GH-1306 regression") {
actor_system_config cfg;
cfg.set("caf.scheduler.max-threads", 1u);
actor_system sys{cfg};
auto aut = sys.spawn([](caf::event_based_actor* self) -> behavior {
return {
[self](int32_t x) {
auto rp = self->make_response_promise();
self->run_delayed(1h, [rp, x]() mutable { rp.deliver(x + x); });
return rp;
},
};
});
scoped_actor self{sys};
self->send(aut, 21);
self->send_exit(aut, exit_reason::kill);
aut = nullptr;
// Destroying the now obsolete action now destroys the promise. If the promise
// access the self pointer this triggers a heap-use-after-free since the AUT
// has been destroyed at this point.
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment