Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid into no_simix_global
[simgrid.git] / src / kernel / EngineImpl.cpp
1 /* Copyright (c) 2016-2021. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "src/kernel/EngineImpl.hpp"
7 #include "mc/mc.h"
8 #include "simgrid/Exception.hpp"
9 #include "simgrid/kernel/Timer.hpp"
10 #include "simgrid/kernel/routing/NetPoint.hpp"
11 #include "simgrid/kernel/routing/NetZoneImpl.hpp"
12 #include "simgrid/s4u/Host.hpp"
13 #include "simgrid/sg_config.hpp"
14 #include "src/include/surf/surf.hpp" //get_clock() and surf_solve()
15 #include "src/kernel/resource/DiskImpl.hpp"
16 #include "src/kernel/resource/profile/Profile.hpp"
17 #include "src/mc/mc_record.hpp"
18 #include "src/mc/mc_replay.hpp"
19 #include "src/smpi/include/smpi_actor.hpp"
20 #include "src/surf/network_interface.hpp"
21 #include "src/surf/xml/platf.hpp" // FIXME: KILLME. There must be a better way than mimicking XML here
22
23 #include <boost/algorithm/string/predicate.hpp>
24 #ifndef _WIN32
25 #include <dlfcn.h>
26 #endif /* _WIN32 */
27
28 #if SIMGRID_HAVE_MC
29 #include "src/mc/remote/AppSide.hpp"
30 #endif
31
32 XBT_LOG_NEW_DEFAULT_CATEGORY(ker_engine, "Logging specific to Engine (kernel)");
33 namespace simgrid {
34 namespace kernel {
35 EngineImpl* EngineImpl::instance_ = nullptr; /* That singleton is awful too. */
36
37 config::Flag<double> cfg_breakpoint{"debug/breakpoint",
38                                     "When non-negative, raise a SIGTRAP after given (simulated) time", -1.0};
39 config::Flag<bool> cfg_verbose_exit{"debug/verbose-exit", "Display the actor status at exit", true};
40 } // namespace kernel
41 } // namespace simgrid
42
43 XBT_ATTRIB_NORETURN static void inthandler(int)
44 {
45   if (simgrid::kernel::cfg_verbose_exit) {
46     XBT_INFO("CTRL-C pressed. The current status will be displayed before exit (disable that behavior with option "
47              "'debug/verbose-exit').");
48     simgrid::kernel::EngineImpl::get_instance()->display_all_actor_status();
49   } else {
50     XBT_INFO("CTRL-C pressed, exiting. Hiding the current process status since 'debug/verbose-exit' is set to false.");
51   }
52   exit(1);
53 }
54
55 #ifndef _WIN32
56 static void segvhandler(int signum, siginfo_t* siginfo, void* /*context*/)
57 {
58   if ((siginfo->si_signo == SIGSEGV && siginfo->si_code == SEGV_ACCERR) || siginfo->si_signo == SIGBUS) {
59     fprintf(stderr,
60             "Access violation or Bus error detected.\n"
61             "This probably comes from a programming error in your code, or from a stack\n"
62             "overflow. If you are certain of your code, try increasing the stack size\n"
63             "   --cfg=contexts/stack-size:XXX (current size is %u KiB).\n"
64             "\n"
65             "If it does not help, this may have one of the following causes:\n"
66             "a bug in SimGrid, a bug in the OS or a bug in a third-party libraries.\n"
67             "Failing hardware can sometimes generate such errors too.\n"
68             "\n"
69             "If you think you've found a bug in SimGrid, please report it along with a\n"
70             "Minimal Working Example (MWE) reproducing your problem and a full backtrace\n"
71             "of the fault captured with gdb or valgrind.\n",
72             smx_context_stack_size / 1024);
73   } else if (siginfo->si_signo == SIGSEGV) {
74     fprintf(stderr, "Segmentation fault.\n");
75 #if HAVE_SMPI
76     if (smpi_enabled() && smpi_cfg_privatization() == SmpiPrivStrategies::NONE) {
77 #if HAVE_PRIVATIZATION
78       fprintf(stderr, "Try to enable SMPI variable privatization with --cfg=smpi/privatization:yes.\n");
79 #else
80       fprintf(stderr, "Sadly, your system does not support --cfg=smpi/privatization:yes (yet).\n");
81 #endif /* HAVE_PRIVATIZATION */
82     }
83 #endif /* HAVE_SMPI */
84   }
85   std::raise(signum);
86 }
87
88 /**
89  * Install signal handler for SIGSEGV.  Check that nobody has already installed
90  * its own handler.  For example, the Java VM does this.
91  */
92 static void install_segvhandler()
93 {
94   stack_t old_stack;
95
96   if (simgrid::kernel::context::Context::install_sigsegv_stack(&old_stack, true) == -1) {
97     XBT_WARN("Failed to register alternate signal stack: %s", strerror(errno));
98     return;
99   }
100   if (not(old_stack.ss_flags & SS_DISABLE)) {
101     XBT_DEBUG("An alternate stack was already installed (sp=%p, size=%zu, flags=%x). Restore it.", old_stack.ss_sp,
102               old_stack.ss_size, (unsigned)old_stack.ss_flags);
103     sigaltstack(&old_stack, nullptr);
104   }
105
106   struct sigaction action;
107   struct sigaction old_action;
108   action.sa_sigaction = &segvhandler;
109   action.sa_flags     = SA_ONSTACK | SA_RESETHAND | SA_SIGINFO;
110   sigemptyset(&action.sa_mask);
111
112   /* Linux tend to raise only SIGSEGV where other systems also raise SIGBUS on severe error */
113   for (int sig : {SIGSEGV, SIGBUS}) {
114     if (sigaction(sig, &action, &old_action) == -1) {
115       XBT_WARN("Failed to register signal handler for signal %d: %s", sig, strerror(errno));
116       continue;
117     }
118     if ((old_action.sa_flags & SA_SIGINFO) || old_action.sa_handler != SIG_DFL) {
119       XBT_DEBUG("A signal handler was already installed for signal %d (%p). Restore it.", sig,
120                 (old_action.sa_flags & SA_SIGINFO) ? (void*)old_action.sa_sigaction : (void*)old_action.sa_handler);
121       sigaction(sig, &old_action, nullptr);
122     }
123   }
124 }
125
126 #endif /* _WIN32 */
127
128 namespace simgrid {
129 namespace kernel {
130
131 EngineImpl::EngineImpl(int* argc, char** argv)
132 {
133   EngineImpl::instance_ = this;
134 }
135
136 EngineImpl::~EngineImpl()
137 {
138   /* Since hosts_ is a std::map, the hosts are destroyed in the lexicographic order, which ensures that the output is
139    * reproducible.
140    */
141   while (not hosts_.empty())
142     hosts_.begin()->second->destroy();
143
144   /* Also delete the other data */
145   delete netzone_root_;
146   for (auto const& kv : netpoints_)
147     delete kv.second;
148
149   for (auto const& kv : links_)
150     if (kv.second)
151       kv.second->destroy();
152
153   for (auto const& kv : mailboxes_)
154     delete kv.second;
155
156     /* Free the remaining data structures */
157 #if SIMGRID_HAVE_MC
158   xbt_dynar_free(&actors_vector_);
159   xbt_dynar_free(&dead_actors_vector_);
160 #endif
161   /* clear models before freeing handle, network models can use external callback defined in the handle */
162   models_prio_.clear();
163 }
164
165 void EngineImpl::initialize(int* argc, char** argv)
166 {
167 #if SIMGRID_HAVE_MC
168   // The communication initialization is done ASAP, as we need to get some init parameters from the MC for different
169   // layers. But simix_global needs to be created, as we send the address of some of its fields to the MC that wants to
170   // read them directly.
171   simgrid::mc::AppSide::initialize();
172 #endif
173
174   surf_init(argc, argv); /* Initialize SURF structures */
175
176   instance_->context_mod_init();
177
178   /* Prepare to display some more info when dying on Ctrl-C pressing */
179   std::signal(SIGINT, inthandler);
180
181 #ifndef _WIN32
182   install_segvhandler();
183 #endif
184
185   /* register a function to be called by SURF after the environment creation */
186   sg_platf_init();
187   s4u::Engine::on_platform_created.connect(surf_presolve);
188
189   if (config::get_value<bool>("debug/clean-atexit"))
190     atexit(shutdown);
191 }
192 void EngineImpl::shutdown()
193 {
194   static bool already_cleaned_up = false;
195   if (already_cleaned_up)
196     return; // to avoid double cleaning by java and C
197   already_cleaned_up = true;
198   XBT_DEBUG("EngineImpl::shutdown() called. Simulation's over.");
199   if (instance_->has_actors_to_run() && simgrid_get_clock() <= 0.0) {
200     XBT_CRITICAL("   ");
201     XBT_CRITICAL("The time is still 0, and you still have processes ready to run.");
202     XBT_CRITICAL("It seems that you forgot to run the simulation that you setup.");
203     xbt_die("Bailing out to avoid that stop-before-start madness. Please fix your code.");
204   }
205
206   /* Kill all actors (but maestro) */
207   instance_->maestro_->kill_all();
208   instance_->run_all_actors();
209   instance_->empty_trash();
210
211 #if HAVE_SMPI
212   if (not instance_->actor_list_.empty()) {
213     if (smpi_process()->initialized()) {
214       xbt_die("Process exited without calling MPI_Finalize - Killing simulation");
215     } else {
216       XBT_WARN("Process called exit when leaving - Skipping cleanups");
217       return;
218     }
219   }
220 #endif
221
222   /* Let's free maestro now */
223   instance_->destroy_maestro();
224
225   /* Finish context module and SURF */
226   instance_->destroy_context_factory();
227
228   while (not timer::kernel_timers().empty()) {
229     delete timer::kernel_timers().top().second;
230     timer::kernel_timers().pop();
231   }
232
233   tmgr_finalize();
234   sg_platf_exit();
235
236   delete instance_;
237   instance_ = nullptr;
238 }
239
240 void EngineImpl::load_platform(const std::string& platf)
241 {
242   double start = xbt_os_time();
243   if (boost::algorithm::ends_with(platf, ".so") or boost::algorithm::ends_with(platf, ".dylib")) {
244 #ifdef _WIN32
245     xbt_die("loading platform through shared library isn't supported on windows");
246 #else
247     void* handle = dlopen(platf.c_str(), RTLD_LAZY);
248     xbt_assert(handle, "Impossible to open platform file: %s", platf.c_str());
249     platf_handle_           = std::unique_ptr<void, std::function<int(void*)>>(handle, dlclose);
250     using load_fct_t = void (*)(const simgrid::s4u::Engine&);
251     auto callable           = (load_fct_t)dlsym(platf_handle_.get(), "load_platform");
252     const char* dlsym_error = dlerror();
253     xbt_assert(not dlsym_error, "Error: %s", dlsym_error);
254     callable(*simgrid::s4u::Engine::get_instance());
255 #endif /* _WIN32 */
256   } else {
257     parse_platform_file(platf);
258   }
259
260   double end = xbt_os_time();
261   XBT_DEBUG("PARSE TIME: %g", (end - start));
262 }
263
264 void EngineImpl::load_deployment(const std::string& file) const
265 {
266   sg_platf_exit();
267   sg_platf_init();
268
269   surf_parse_open(file);
270   surf_parse();
271   surf_parse_close();
272 }
273
274 void EngineImpl::register_function(const std::string& name, const actor::ActorCodeFactory& code)
275 {
276   registered_functions[name] = code;
277 }
278 void EngineImpl::register_default(const actor::ActorCodeFactory& code)
279 {
280   default_function = code;
281 }
282
283 void EngineImpl::add_model(std::shared_ptr<resource::Model> model, const std::vector<resource::Model*>& dependencies)
284 {
285   auto model_name = model->get_name();
286   xbt_assert(models_prio_.find(model_name) == models_prio_.end(),
287              "Model %s already exists, use model.set_name() to change its name", model_name.c_str());
288
289   for (const auto dep : dependencies) {
290     xbt_assert(models_prio_.find(dep->get_name()) != models_prio_.end(),
291                "Model %s doesn't exists. Impossible to use it as dependency.", dep->get_name().c_str());
292   }
293   models_.push_back(model.get());
294   models_prio_[model_name] = std::move(model);
295 }
296
297 void EngineImpl::add_split_duplex_link(const std::string& name, std::unique_ptr<resource::SplitDuplexLinkImpl> link)
298 {
299   split_duplex_links_[name] = std::move(link);
300 }
301
302 /** Wake up all actors waiting for a Surf action to finish */
303 void EngineImpl::wake_all_waiting_actors() const
304 {
305   for (auto const& model : models_) {
306     XBT_DEBUG("Handling the failed actions (if any)");
307     while (auto* action = model->extract_failed_action()) {
308       XBT_DEBUG("   Handling Action %p", action);
309       if (action->get_activity() != nullptr)
310         activity::ActivityImplPtr(action->get_activity())->post();
311     }
312     XBT_DEBUG("Handling the terminated actions (if any)");
313     while (auto* action = model->extract_done_action()) {
314       XBT_DEBUG("   Handling Action %p", action);
315       if (action->get_activity() == nullptr)
316         XBT_DEBUG("probably vcpu's action %p, skip", action);
317       else
318         activity::ActivityImplPtr(action->get_activity())->post();
319     }
320   }
321 }
322 /**
323  * @brief Executes the actors in actors_to_run.
324  *
325  * The actors in actors_to_run are run (in parallel if possible). On exit, actors_to_run is empty, and actors_that_ran
326  * contains the list of actors that just ran.  The two lists are swapped so, be careful when using them before and after
327  * a call to this function.
328  */
329 void EngineImpl::run_all_actors()
330 {
331   instance_->get_context_factory()->run_all();
332
333   actors_to_run_.swap(actors_that_ran_);
334   actors_to_run_.clear();
335 }
336
337 actor::ActorImpl* EngineImpl::get_actor_by_pid(aid_t pid)
338 {
339   auto item = actor_list_.find(pid);
340   if (item != actor_list_.end())
341     return item->second;
342
343   // Search the trash
344   for (auto& a : actors_to_destroy_)
345     if (a.get_pid() == pid)
346       return &a;
347   return nullptr; // Not found, even in the trash
348 }
349
350 /** Execute all the tasks that are queued, e.g. `.then()` callbacks of futures. */
351 bool EngineImpl::execute_tasks()
352 {
353   if (tasks.empty())
354     return false;
355
356   std::vector<xbt::Task<void()>> tasksTemp;
357   do {
358     // We don't want the callbacks to modify the vector we are iterating over:
359     tasks.swap(tasksTemp);
360
361     // Execute all the queued tasks:
362     for (auto& task : tasksTemp)
363       task();
364
365     tasksTemp.clear();
366   } while (not tasks.empty());
367
368   return true;
369 }
370
371 void EngineImpl::remove_daemon(actor::ActorImpl* actor)
372 {
373   auto it = daemons_.find(actor);
374   xbt_assert(it != daemons_.end(), "The dying daemon is not a daemon after all. Please report that bug.");
375   daemons_.erase(it);
376 }
377
378 void EngineImpl::add_actor_to_run_list_no_check(actor::ActorImpl* actor)
379 {
380   XBT_DEBUG("Inserting [%p] %s(%s) in the to_run list", actor, actor->get_cname(), actor->get_host()->get_cname());
381   actors_to_run_.push_back(actor);
382 }
383
384 void EngineImpl::add_actor_to_run_list(actor::ActorImpl* actor)
385 {
386   if (std::find(begin(actors_to_run_), end(actors_to_run_), actor) != end(actors_to_run_)) {
387     XBT_DEBUG("Actor %s is already in the to_run list", actor->get_cname());
388   } else {
389     XBT_DEBUG("Inserting [%p] %s(%s) in the to_run list", actor, actor->get_cname(), actor->get_host()->get_cname());
390     actors_to_run_.push_back(actor);
391   }
392 }
393 void EngineImpl::empty_trash()
394 {
395   while (not actors_to_destroy_.empty()) {
396     actor::ActorImpl* actor = &actors_to_destroy_.front();
397     actors_to_destroy_.pop_front();
398     XBT_DEBUG("Getting rid of %s (refcount: %d)", actor->get_cname(), actor->get_refcount());
399     intrusive_ptr_release(actor);
400   }
401 #if SIMGRID_HAVE_MC
402   xbt_dynar_reset(dead_actors_vector_);
403 #endif
404 }
405
406 void EngineImpl::display_all_actor_status() const
407 {
408   XBT_INFO("%zu actors are still running, waiting for something.", actor_list_.size());
409   /*  List the actors and their state */
410   XBT_INFO("Legend of the following listing: \"Actor <pid> (<name>@<host>): <status>\"");
411   for (auto const& kv : actor_list_) {
412     actor::ActorImpl* actor = kv.second;
413
414     if (actor->waiting_synchro_) {
415       const char* synchro_description = "unknown";
416
417       if (boost::dynamic_pointer_cast<kernel::activity::ExecImpl>(actor->waiting_synchro_) != nullptr)
418         synchro_description = "execution";
419
420       if (boost::dynamic_pointer_cast<kernel::activity::CommImpl>(actor->waiting_synchro_) != nullptr)
421         synchro_description = "communication";
422
423       if (boost::dynamic_pointer_cast<kernel::activity::SleepImpl>(actor->waiting_synchro_) != nullptr)
424         synchro_description = "sleeping";
425
426       if (boost::dynamic_pointer_cast<kernel::activity::RawImpl>(actor->waiting_synchro_) != nullptr)
427         synchro_description = "synchronization";
428
429       if (boost::dynamic_pointer_cast<kernel::activity::IoImpl>(actor->waiting_synchro_) != nullptr)
430         synchro_description = "I/O";
431
432       XBT_INFO("Actor %ld (%s@%s): waiting for %s activity %#zx (%s) in state %d to finish", actor->get_pid(),
433                actor->get_cname(), actor->get_host()->get_cname(), synchro_description,
434                (xbt_log_no_loc ? (size_t)0xDEADBEEF : (size_t)actor->waiting_synchro_.get()),
435                actor->waiting_synchro_->get_cname(), (int)actor->waiting_synchro_->state_);
436     } else {
437       XBT_INFO("Actor %ld (%s@%s) simcall %s", actor->get_pid(), actor->get_cname(), actor->get_host()->get_cname(),
438                SIMIX_simcall_name(actor->simcall_));
439     }
440   }
441 }
442
443 void EngineImpl::run()
444 {
445   if (MC_record_replay_is_active()) {
446     mc::replay(MC_record_path());
447     empty_trash();
448     return;
449   }
450
451   double time = 0;
452
453   do {
454     XBT_DEBUG("New Schedule Round; size(queue)=%zu", actors_to_run_.size());
455
456     if (cfg_breakpoint >= 0.0 && surf_get_clock() >= cfg_breakpoint) {
457       XBT_DEBUG("Breakpoint reached (%g)", cfg_breakpoint.get());
458       cfg_breakpoint = -1.0;
459 #ifdef SIGTRAP
460       std::raise(SIGTRAP);
461 #else
462       std::raise(SIGABRT);
463 #endif
464     }
465
466     execute_tasks();
467
468     while (not actors_to_run_.empty()) {
469       XBT_DEBUG("New Sub-Schedule Round; size(queue)=%zu", actors_to_run_.size());
470
471       /* Run all actors that are ready to run, possibly in parallel */
472       run_all_actors();
473
474       /* answer sequentially and in a fixed arbitrary order all the simcalls that were issued during that sub-round */
475
476       /* WARNING, the order *must* be fixed or you'll jeopardize the simulation reproducibility (see RR-7653) */
477
478       /* Here, the order is ok because:
479        *
480        *   Short proof: only maestro adds stuff to the actors_to_run array, so the execution order of user contexts do
481        *   not impact its order.
482        *
483        *   Long proof: actors remain sorted through an arbitrary (implicit, complex but fixed) order in all cases.
484        *
485        *   - if there is no kill during the simulation, actors remain sorted according by their PID.
486        *     Rationale: This can be proved inductively.
487        *        Assume that actors_to_run is sorted at a beginning of one round (it is at round 0: the deployment file
488        *        is parsed linearly).
489        *        Let's show that it is still so at the end of this round.
490        *        - if an actor is added when being created, that's from maestro. It can be either at startup
491        *          time (and then in PID order), or in response to a process_create simcall. Since simcalls are handled
492        *          in arbitrary order (inductive hypothesis), we are fine.
493        *        - If an actor is added because it's getting killed, its subsequent actions shouldn't matter
494        *        - If an actor gets added to actors_to_run because one of their blocking action constituting the meat
495        *          of a simcall terminates, we're still good. Proof:
496        *          - You are added from ActorImpl::simcall_answer() only. When this function is called depends on the
497        *            resource kind (network, cpu, disk, whatever), but the same arguments hold. Let's take communications
498        *            as an example.
499        *          - For communications, this function is called from SIMIX_comm_finish().
500        *            This function itself don't mess with the order since simcalls are handled in FIFO order.
501        *            The function is called:
502        *            - before the comm starts (invalid parameters, or resource already dead or whatever).
503        *              The order then trivial holds since maestro didn't interrupt its handling of the simcall yet
504        *            - because the communication failed or were canceled after startup. In this case, it's called from
505        *              the function we are in, by the chunk:
506        *                       set = model->states.failed_action_set;
507        *                       while ((synchro = extract(set)))
508        *                          SIMIX_simcall_post((smx_synchro_t) synchro->data);
509        *              This order is also fixed because it depends of the order in which the surf actions were
510        *              added to the system, and only maestro can add stuff this way, through simcalls.
511        *              We thus use the inductive hypothesis once again to conclude that the order in which synchros are
512        *              popped out of the set does not depend on the user code's execution order.
513        *            - because the communication terminated. In this case, synchros are served in the order given by
514        *                       set = model->states.done_action_set;
515        *                       while ((synchro = extract(set)))
516        *                          SIMIX_simcall_post((smx_synchro_t) synchro->data);
517        *              and the argument is very similar to the previous one.
518        *            So, in any case, the orders of calls to CommImpl::finish() do not depend on the order in which user
519        *            actors are executed.
520        *          So, in any cases, the orders of actors within actors_to_run do not depend on the order in which
521        *          user actors were executed previously.
522        *     So, if there is no killing in the simulation, the simulation reproducibility is not jeopardized.
523        *   - If there is some actor killings, the order is changed by this decision that comes from user-land
524        *     But this decision may not have been motivated by a situation that were different because the simulation is
525        *     not reproducible.
526        *     So, even the order change induced by the actor killing is perfectly reproducible.
527        *
528        *   So science works, bitches [http://xkcd.com/54/].
529        *
530        *   We could sort the actors_that_ran array completely so that we can describe the order in which simcalls are
531        *   handled (like "according to the PID of issuer"), but it's not mandatory (order is fixed already even if
532        *   unfriendly).
533        *   That would thus be a pure waste of time.
534        */
535
536       for (auto const& actor : actors_that_ran_) {
537         if (actor->simcall_.call_ != simix::Simcall::NONE) {
538           actor->simcall_handle(0);
539         }
540       }
541
542       execute_tasks();
543       do {
544         wake_all_waiting_actors();
545       } while (execute_tasks());
546
547       /* If only daemon actors remain, cancel their actions, mark them to die and reschedule them */
548       if (actor_list_.size() == daemons_.size())
549         for (auto const& dmon : daemons_) {
550           XBT_DEBUG("Kill %s", dmon->get_cname());
551           maestro_->kill(dmon);
552         }
553     }
554
555     time = timer::Timer::next();
556     if (time > -1.0 || not actor_list_.empty()) {
557       XBT_DEBUG("Calling surf_solve");
558       time = surf_solve(time);
559       XBT_DEBUG("Moving time ahead : %g", time);
560     }
561
562     /* Notify all the hosts that have failed */
563     /* FIXME: iterate through the list of failed host and mark each of them */
564     /* as failed. On each host, signal all the running actors with host_fail */
565
566     // Execute timers and tasks until there isn't anything to be done:
567     bool again = false;
568     do {
569       again = timer::Timer::execute_all();
570       if (execute_tasks())
571         again = true;
572       wake_all_waiting_actors();
573     } while (again);
574
575     /* Clean actors to destroy */
576     empty_trash();
577
578     XBT_DEBUG("### time %f, #actors %zu, #to_run %zu", time, actor_list_.size(), actors_to_run_.size());
579
580     if (time < 0. && actors_to_run_.empty() && not actor_list_.empty()) {
581       if (actor_list_.size() <= daemons_.size()) {
582         XBT_CRITICAL("Oops! Daemon actors cannot do any blocking activity (communications, synchronization, etc) "
583                      "once the simulation is over. Please fix your on_exit() functions.");
584       } else {
585         XBT_CRITICAL("Oops! Deadlock or code not perfectly clean.");
586       }
587       display_all_actor_status();
588       simgrid::s4u::Engine::on_deadlock();
589       for (auto const& kv : actor_list_) {
590         XBT_DEBUG("Kill %s", kv.second->get_cname());
591         maestro_->kill(kv.second);
592       }
593     }
594   } while (time > -1.0 || has_actors_to_run());
595
596   if (not actor_list_.empty())
597     THROW_IMPOSSIBLE;
598
599   simgrid::s4u::Engine::on_simulation_end();
600 }
601 } // namespace kernel
602 } // namespace simgrid