Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix invalid free when SIMIX_global_init() exits early.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 5 Oct 2017 19:48:33 +0000 (21:48 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 5 Oct 2017 20:31:34 +0000 (22:31 +0200)
src/s4u/s4u_engine.cpp

index 07fa11b..783ed43 100644 (file)
@@ -32,11 +32,11 @@ Engine *Engine::instance_ = nullptr; /* That singleton is awful, but I don't see
 
 Engine::Engine(int *argc, char **argv) {
   xbt_assert(s4u::Engine::instance_ == nullptr, "It is currently forbidden to create more than one instance of s4u::Engine");
-  s4u::Engine::instance_ = this;
-  pimpl                  = new kernel::EngineImpl();
-
   TRACE_global_init();
   SIMIX_global_init(argc, argv);
+
+  pimpl                  = new kernel::EngineImpl();
+  s4u::Engine::instance_ = this;
 }
 
 Engine::~Engine()
@@ -54,6 +54,7 @@ Engine* Engine::getInstance()
 
 void Engine::shutdown() {
   delete s4u::Engine::instance_;
+  s4u::Engine::instance_ = nullptr;
 }
 
 double Engine::getClock()