From 0ed5c8db39ee51d5dd40f68f9cb68e91aed270c4 Mon Sep 17 00:00:00 2001 From: Pauli Date: Thu, 5 Jul 2018 21:18:49 +0300 Subject: [PATCH] Fix data race between threaded init and EventManager The initial run_dfhack_init loads shared state information that is used by EventManager when state changes. There is a small risk that EventManager can handle events while run_dfhack_init is still running. --- library/Core.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/library/Core.cpp b/library/Core.cpp index c406fb6c0..c724a0fcc 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -1427,6 +1427,7 @@ bool Core::loadScriptFile(color_ostream &out, string fname, bool silent) static void run_dfhack_init(color_ostream &out, Core *core) { + CoreSuspender lock; if (!df::global::world || !df::global::ui || !df::global::gview) { out.printerr("Key globals are missing, skipping loading dfhack.init.\n");