From 0bb417fd1d7a11dea0512b1a24476396d08c700b Mon Sep 17 00:00:00 2001 From: Florian Schmaus <flow@cs.fau.de> Date: Wed, 24 Mar 2021 13:11:14 +0100 Subject: [PATCH] [TellActorFromAnywhereTest] Heap allocate Actor and BPS Allocate the Actor and the BPS on the heap as otherwise Fibers may access already destructed Actor data. --- tests/TellActorFromAnywhereTest.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/TellActorFromAnywhereTest.cpp b/tests/TellActorFromAnywhereTest.cpp index 70800ac1..3e63f1f1 100644 --- a/tests/TellActorFromAnywhereTest.cpp +++ b/tests/TellActorFromAnywhereTest.cpp @@ -18,14 +18,16 @@ class SignallingActor : public Actor<unsigned int> { }; void emperTest() { - BinaryPrivateSemaphore bps; - SignallingActor signallingActor(bps); - signallingActor.start(); + // Heap allocate the Actor and the BPS until we have a way to + // cleanly terminate the Actor. + auto* bps = new BinaryPrivateSemaphore(); + auto* signallingActor = new SignallingActor(*bps); + signallingActor->start(); // TODO: Use std::jthread once EMPER uses C++20. - std::thread signallingThread([&] { signallingActor.tellFromAnywhere(1); }); + std::thread signallingThread([&] { signallingActor->tellFromAnywhere(1); }); - bps.wait(); + bps->wait(); // TODO: Remove this once we use std::jthread when EMPER uses C++20. signallingThread.join(); -- GitLab