From 2c8343aa8233333dae0caf91f25bf1fe4689c88e Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 22 May 2017 16:05:58 -0700 Subject: [core] Block in Mailbox::close() until neither receive nor push are in progress MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise, an ActorRef that's in the process of sending a message could attempt to access an invalid Scheduler reference: Thread 1 Thread 2 -------------------------------------------------- Scheduler::Scheduler Actor::Actor weakMailbox.lock() Actor::~Actor Scheduler::~Scheduler mailbox->push() scheduler.schedule() 💣 --- include/mbgl/actor/mailbox.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/mbgl') diff --git a/include/mbgl/actor/mailbox.hpp b/include/mbgl/actor/mailbox.hpp index cff0de243a..1327e8e6fe 100644 --- a/include/mbgl/actor/mailbox.hpp +++ b/include/mbgl/actor/mailbox.hpp @@ -23,8 +23,10 @@ public: private: Scheduler& scheduler; - std::mutex closingMutex; - bool closing { false }; + std::mutex receivingMutex; + std::mutex pushingMutex; + + bool closed { false }; std::mutex queueMutex; std::queue> queue; -- cgit v1.2.1