Logo AND Algorithmique Numérique Distribuée

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