Commit 3b44fa23 authored by Marian Triebe's avatar Marian Triebe

Fix Heap-use-after-free with hidden actors

parent e1c9577a
......@@ -122,9 +122,6 @@ void actor_registry::await_running_count_equal(size_t expected) {
CAF_LOG_DEBUG("count = " << m_running.load());
m_running_cv.wait(guard);
}
// also wait for all detached threads to make sure
// destructore were called correctly
scheduler::await_detached_threads();
}
} // namespace detail
......
......@@ -478,10 +478,7 @@ void local_actor::launch(execution_unit* eu, bool lazy, bool hide) {
// actor lives in its own thread
CAF_PUSH_AID(id());
CAF_LOG_TRACE(CAF_ARG(lazy) << ", " << CAF_ARG(hide));
if (!hide) {
// hiding the actor also hides the thread
scheduler::inc_detached_threads();
}
scheduler::inc_detached_threads();
//intrusive_ptr<local_actor> mself{this};
std::thread{[hide](intrusive_ptr<local_actor> mself) {
// this extra scope makes sure that the trace logger is
......@@ -497,9 +494,7 @@ void local_actor::launch(execution_unit* eu, bool lazy, bool hide) {
}
mself.reset();
}
if (!hide) {
scheduler::dec_detached_threads();
}
scheduler::dec_detached_threads();
}, intrusive_ptr<local_actor>{this}}.detach();
return;
}
......
......@@ -21,6 +21,7 @@
#include "caf/message.hpp"
#include "caf/exception.hpp"
#include "caf/scheduler.hpp"
#include "caf/local_actor.hpp"
#include "caf/scheduler/abstract_coordinator.hpp"
......@@ -77,6 +78,8 @@ void singletons::stop_singletons() {
stop(s_group_manager);
CAF_LOGF_DEBUG("stop scheduler");
stop(s_scheduling_coordinator);
CAF_LOGF_DEBUG("wait for all detached threads");
scheduler::await_detached_threads();
CAF_LOGF_DEBUG("stop actor registry");
stop(s_actor_registry);
// dispose singletons, i.e., release memory
......@@ -91,13 +94,13 @@ void singletons::stop_singletons() {
CAF_LOGF_DEBUG("dispose registry");
dispose(s_actor_registry);
// final steps
CAF_LOGF_DEBUG("stop and dispose logger, bye");
stop(s_logger);
dispose(s_logger);
stop(s_uniform_type_info_map);
dispose(s_uniform_type_info_map);
stop(s_node_id);
dispose(s_node_id);
CAF_LOGF_DEBUG("stop and dispose logger, bye");
stop(s_logger);
dispose(s_logger);
}
actor_registry* singletons::get_actor_registry() {
......
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