Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
handle suicidal MPI apps first
[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 #include "xbt/xbt_modinter.h"     /* whether initialization was already done */
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()
133 {
134   /* Since hosts_ is a std::map, the hosts are destroyed in the lexicographic order, which ensures that the output is
135    * reproducible.
136    */
137   while (not hosts_.empty())
138     hosts_.begin()->second->destroy();
139
140   /* Also delete the other data */
141   delete netzone_root_;
142   for (auto const& kv : netpoints_)
143     delete kv.second;
144
145   for (auto const& kv : links_)
146     if (kv.second)
147       kv.second->destroy();
148
149   for (auto const& kv : mailboxes_)
150     delete kv.second;
151
152     /* Free the remaining data structures */
153 #if SIMGRID_HAVE_MC
154   xbt_dynar_free(&actors_vector_);
155   xbt_dynar_free(&dead_actors_vector_);
156 #endif
157   /* clear models before freeing handle, network models can use external callback defined in the handle */
158   models_prio_.clear();
159 }
160
161 void EngineImpl::initialize(int* argc, char** argv)
162 {
163   xbt_assert(EngineImpl::instance_ == nullptr,
164              "It is currently forbidden to create more than one instance of kernel::EngineImpl");
165   EngineImpl::instance_ = this;
166 #if SIMGRID_HAVE_MC
167   // The communication initialization is done ASAP, as we need to get some init parameters from the MC for different
168   // layers. But simix_global needs to be created, as we send the address of some of its fields to the MC that wants to
169   // read them directly.
170   simgrid::mc::AppSide::initialize();
171 #endif
172
173   if (xbt_initialized == 0) {
174     xbt_init(argc, argv);
175
176     sg_config_init(argc, argv);
177   }
178
179   instance_->context_mod_init();
180
181   /* Prepare to display some more info when dying on Ctrl-C pressing */
182   std::signal(SIGINT, inthandler);
183
184 #ifndef _WIN32
185   install_segvhandler();
186 #endif
187
188   /* register a function to be called by SURF after the environment creation */
189   sg_platf_init();
190   s4u::Engine::on_platform_created.connect(surf_presolve);
191
192   if (config::get_value<bool>("debug/clean-atexit"))
193     atexit(shutdown);
194 }
195
196 void EngineImpl::shutdown()
197 {
198   if (EngineImpl::instance_ == nullptr)
199     return;
200   XBT_DEBUG("EngineImpl::shutdown() called. Simulation's over.");
201   if (instance_->has_actors_to_run() && simgrid_get_clock() <= 0.0) {
202     XBT_CRITICAL("   ");
203     XBT_CRITICAL("The time is still 0, and you still have processes ready to run.");
204     XBT_CRITICAL("It seems that you forgot to run the simulation that you setup.");
205     xbt_die("Bailing out to avoid that stop-before-start madness. Please fix your code.");
206   }
207
208 #if HAVE_SMPI
209   if (not instance_->actor_list_.empty()) {
210     if (smpi_process()->initialized()) {
211       xbt_die("Process exited without calling MPI_Finalize - Killing simulation");
212     } else {
213       XBT_WARN("Process called exit when leaving - Skipping cleanups");
214       return;
215     }
216   }
217 #endif
218
219   /* Kill all actors (but maestro) */
220   instance_->maestro_->kill_all();
221   instance_->run_all_actors();
222   instance_->empty_trash();
223
224   /* Let's free maestro now */
225   instance_->destroy_maestro();
226
227   /* Finish context module and SURF */
228   instance_->destroy_context_factory();
229
230   while (not timer::kernel_timers().empty()) {
231     delete timer::kernel_timers().top().second;
232     timer::kernel_timers().pop();
233   }
234
235   tmgr_finalize();
236   sg_platf_exit();
237
238   delete instance_;
239   instance_ = nullptr;
240 }
241
242 void EngineImpl::load_platform(const std::string& platf)
243 {
244   double start = xbt_os_time();
245   if (boost::algorithm::ends_with(platf, ".so") or boost::algorithm::ends_with(platf, ".dylib")) {
246 #ifdef _WIN32
247     xbt_die("loading platform through shared library isn't supported on windows");
248 #else
249     void* handle = dlopen(platf.c_str(), RTLD_LAZY);
250     xbt_assert(handle, "Impossible to open platform file: %s", platf.c_str());
251     platf_handle_           = std::unique_ptr<void, std::function<int(void*)>>(handle, dlclose);
252     using load_fct_t = void (*)(const simgrid::s4u::Engine&);
253     auto callable           = (load_fct_t)dlsym(platf_handle_.get(), "load_platform");
254     const char* dlsym_error = dlerror();
255     xbt_assert(not dlsym_error, "Error: %s", dlsym_error);
256     callable(*simgrid::s4u::Engine::get_instance());
257 #endif /* _WIN32 */
258   } else {
259     parse_platform_file(platf);
260   }
261
262   double end = xbt_os_time();
263   XBT_DEBUG("PARSE TIME: %g", (end - start));
264 }
265
266 void EngineImpl::load_deployment(const std::string& file) const
267 {
268   sg_platf_exit();
269   sg_platf_init();
270
271   surf_parse_open(file);
272   surf_parse();
273   surf_parse_close();
274 }
275
276 void EngineImpl::register_function(const std::string& name, const actor::ActorCodeFactory& code)
277 {
278   registered_functions[name] = code;
279 }
280 void EngineImpl::register_default(const actor::ActorCodeFactory& code)
281 {
282   default_function = code;
283 }
284
285 void EngineImpl::add_model(std::shared_ptr<resource::Model> model, const std::vector<resource::Model*>& dependencies)
286 {
287   auto model_name = model->get_name();
288   xbt_assert(models_prio_.find(model_name) == models_prio_.end(),
289              "Model %s already exists, use model.set_name() to change its name", model_name.c_str());
290
291   for (const auto dep : dependencies) {
292     xbt_assert(models_prio_.find(dep->get_name()) != models_prio_.end(),
293                "Model %s doesn't exists. Impossible to use it as dependency.", dep->get_name().c_str());
294   }
295   models_.push_back(model.get());
296   models_prio_[model_name] = std::move(model);
297 }
298
299 void EngineImpl::add_split_duplex_link(const std::string& name, std::unique_ptr<resource::SplitDuplexLinkImpl> link)
300 {
301   split_duplex_links_[name] = std::move(link);
302 }
303
304 /** Wake up all actors waiting for a Surf action to finish */
305 void EngineImpl::wake_all_waiting_actors() const
306 {
307   for (auto const& model : models_) {
308     XBT_DEBUG("Handling the failed actions (if any)");
309     while (auto* action = model->extract_failed_action()) {
310       XBT_DEBUG("   Handling Action %p", action);
311       if (action->get_activity() != nullptr)
312         activity::ActivityImplPtr(action->get_activity())->post();
313     }
314     XBT_DEBUG("Handling the terminated actions (if any)");
315     while (auto* action = model->extract_done_action()) {
316       XBT_DEBUG("   Handling Action %p", action);
317       if (action->get_activity() == nullptr)
318         XBT_DEBUG("probably vcpu's action %p, skip", action);
319       else
320         activity::ActivityImplPtr(action->get_activity())->post();
321     }
322   }
323 }
324 /**
325  * @brief Executes the actors in actors_to_run.
326  *
327  * The actors in actors_to_run are run (in parallel if possible). On exit, actors_to_run is empty, and actors_that_ran
328  * contains the list of actors that just ran.  The two lists are swapped so, be careful when using them before and after
329  * a call to this function.
330  */
331 void EngineImpl::run_all_actors()
332 {
333   instance_->get_context_factory()->run_all();
334
335   actors_to_run_.swap(actors_that_ran_);
336   actors_to_run_.clear();
337 }
338
339 actor::ActorImpl* EngineImpl::get_actor_by_pid(aid_t pid)
340 {
341   auto item = actor_list_.find(pid);
342   if (item != actor_list_.end())
343     return item->second;
344
345   // Search the trash
346   for (auto& a : actors_to_destroy_)
347     if (a.get_pid() == pid)
348       return &a;
349   return nullptr; // Not found, even in the trash
350 }
351
352 /** Execute all the tasks that are queued, e.g. `.then()` callbacks of futures. */
353 bool EngineImpl::execute_tasks()
354 {
355   if (tasks.empty())
356     return false;
357
358   std::vector<xbt::Task<void()>> tasksTemp;
359   do {
360     // We don't want the callbacks to modify the vector we are iterating over:
361     tasks.swap(tasksTemp);
362
363     // Execute all the queued tasks:
364     for (auto& task : tasksTemp)
365       task();
366
367     tasksTemp.clear();
368   } while (not tasks.empty());
369
370   return true;
371 }
372
373 void EngineImpl::remove_daemon(actor::ActorImpl* actor)
374 {
375   auto it = daemons_.find(actor);
376   xbt_assert(it != daemons_.end(), "The dying daemon is not a daemon after all. Please report that bug.");
377   daemons_.erase(it);
378 }
379
380 void EngineImpl::add_actor_to_run_list_no_check(actor::ActorImpl* actor)
381 {
382   XBT_DEBUG("Inserting [%p] %s(%s) in the to_run list", actor, actor->get_cname(), actor->get_host()->get_cname());
383   actors_to_run_.push_back(actor);
384 }
385
386 void EngineImpl::add_actor_to_run_list(actor::ActorImpl* actor)
387 {
388   if (std::find(begin(actors_to_run_), end(actors_to_run_), actor) != end(actors_to_run_)) {
389     XBT_DEBUG("Actor %s is already in the to_run list", actor->get_cname());
390   } else {
391     XBT_DEBUG("Inserting [%p] %s(%s) in the to_run list", actor, actor->get_cname(), actor->get_host()->get_cname());
392     actors_to_run_.push_back(actor);
393   }
394 }
395 void EngineImpl::empty_trash()
396 {
397   while (not actors_to_destroy_.empty()) {
398     actor::ActorImpl* actor = &actors_to_destroy_.front();
399     actors_to_destroy_.pop_front();
400     XBT_DEBUG("Getting rid of %s (refcount: %d)", actor->get_cname(), actor->get_refcount());
401     intrusive_ptr_release(actor);
402   }
403 #if SIMGRID_HAVE_MC
404   xbt_dynar_reset(dead_actors_vector_);
405 #endif
406 }
407
408 void EngineImpl::display_all_actor_status() const
409 {
410   XBT_INFO("%zu actors are still running, waiting for something.", actor_list_.size());
411   /*  List the actors and their state */
412   XBT_INFO("Legend of the following listing: \"Actor <pid> (<name>@<host>): <status>\"");
413   for (auto const& kv : actor_list_) {
414     actor::ActorImpl* actor = kv.second;
415
416     if (actor->waiting_synchro_) {
417       const char* synchro_description = "unknown";
418
419       if (boost::dynamic_pointer_cast<kernel::activity::ExecImpl>(actor->waiting_synchro_) != nullptr)
420         synchro_description = "execution";
421
422       if (boost::dynamic_pointer_cast<kernel::activity::CommImpl>(actor->waiting_synchro_) != nullptr)
423         synchro_description = "communication";
424
425       if (boost::dynamic_pointer_cast<kernel::activity::SleepImpl>(actor->waiting_synchro_) != nullptr)
426         synchro_description = "sleeping";
427
428       if (boost::dynamic_pointer_cast<kernel::activity::RawImpl>(actor->waiting_synchro_) != nullptr)
429         synchro_description = "synchronization";
430
431       if (boost::dynamic_pointer_cast<kernel::activity::IoImpl>(actor->waiting_synchro_) != nullptr)
432         synchro_description = "I/O";
433
434       XBT_INFO("Actor %ld (%s@%s): waiting for %s activity %#zx (%s) in state %d to finish", actor->get_pid(),
435                actor->get_cname(), actor->get_host()->get_cname(), synchro_description,
436                (xbt_log_no_loc ? (size_t)0xDEADBEEF : (size_t)actor->waiting_synchro_.get()),
437                actor->waiting_synchro_->get_cname(), (int)actor->waiting_synchro_->state_);
438     } else {
439       XBT_INFO("Actor %ld (%s@%s) simcall %s", actor->get_pid(), actor->get_cname(), actor->get_host()->get_cname(),
440                SIMIX_simcall_name(actor->simcall_));
441     }
442   }
443 }
444
445 void EngineImpl::run()
446 {
447   if (MC_record_replay_is_active()) {
448     mc::replay(MC_record_path());
449     empty_trash();
450     return;
451   }
452
453   double time = 0;
454
455   do {
456     XBT_DEBUG("New Schedule Round; size(queue)=%zu", actors_to_run_.size());
457
458     if (cfg_breakpoint >= 0.0 && surf_get_clock() >= cfg_breakpoint) {
459       XBT_DEBUG("Breakpoint reached (%g)", cfg_breakpoint.get());
460       cfg_breakpoint = -1.0;
461 #ifdef SIGTRAP
462       std::raise(SIGTRAP);
463 #else
464       std::raise(SIGABRT);
465 #endif
466     }
467
468     execute_tasks();
469
470     while (not actors_to_run_.empty()) {
471       XBT_DEBUG("New Sub-Schedule Round; size(queue)=%zu", actors_to_run_.size());
472
473       /* Run all actors that are ready to run, possibly in parallel */
474       run_all_actors();
475
476       /* answer sequentially and in a fixed arbitrary order all the simcalls that were issued during that sub-round */
477
478       /* WARNING, the order *must* be fixed or you'll jeopardize the simulation reproducibility (see RR-7653) */
479
480       /* Here, the order is ok because:
481        *
482        *   Short proof: only maestro adds stuff to the actors_to_run array, so the execution order of user contexts do
483        *   not impact its order.
484        *
485        *   Long proof: actors remain sorted through an arbitrary (implicit, complex but fixed) order in all cases.
486        *
487        *   - if there is no kill during the simulation, actors remain sorted according by their PID.
488        *     Rationale: This can be proved inductively.
489        *        Assume that actors_to_run is sorted at a beginning of one round (it is at round 0: the deployment file
490        *        is parsed linearly).
491        *        Let's show that it is still so at the end of this round.
492        *        - if an actor is added when being created, that's from maestro. It can be either at startup
493        *          time (and then in PID order), or in response to a process_create simcall. Since simcalls are handled
494        *          in arbitrary order (inductive hypothesis), we are fine.
495        *        - If an actor is added because it's getting killed, its subsequent actions shouldn't matter
496        *        - If an actor gets added to actors_to_run because one of their blocking action constituting the meat
497        *          of a simcall terminates, we're still good. Proof:
498        *          - You are added from ActorImpl::simcall_answer() only. When this function is called depends on the
499        *            resource kind (network, cpu, disk, whatever), but the same arguments hold. Let's take communications
500        *            as an example.
501        *          - For communications, this function is called from SIMIX_comm_finish().
502        *            This function itself don't mess with the order since simcalls are handled in FIFO order.
503        *            The function is called:
504        *            - before the comm starts (invalid parameters, or resource already dead or whatever).
505        *              The order then trivial holds since maestro didn't interrupt its handling of the simcall yet
506        *            - because the communication failed or were canceled after startup. In this case, it's called from
507        *              the function we are in, by the chunk:
508        *                       set = model->states.failed_action_set;
509        *                       while ((synchro = extract(set)))
510        *                          SIMIX_simcall_post((smx_synchro_t) synchro->data);
511        *              This order is also fixed because it depends of the order in which the surf actions were
512        *              added to the system, and only maestro can add stuff this way, through simcalls.
513        *              We thus use the inductive hypothesis once again to conclude that the order in which synchros are
514        *              popped out of the set does not depend on the user code's execution order.
515        *            - because the communication terminated. In this case, synchros are served in the order given by
516        *                       set = model->states.done_action_set;
517        *                       while ((synchro = extract(set)))
518        *                          SIMIX_simcall_post((smx_synchro_t) synchro->data);
519        *              and the argument is very similar to the previous one.
520        *            So, in any case, the orders of calls to CommImpl::finish() do not depend on the order in which user
521        *            actors are executed.
522        *          So, in any cases, the orders of actors within actors_to_run do not depend on the order in which
523        *          user actors were executed previously.
524        *     So, if there is no killing in the simulation, the simulation reproducibility is not jeopardized.
525        *   - If there is some actor killings, the order is changed by this decision that comes from user-land
526        *     But this decision may not have been motivated by a situation that were different because the simulation is
527        *     not reproducible.
528        *     So, even the order change induced by the actor killing is perfectly reproducible.
529        *
530        *   So science works, bitches [http://xkcd.com/54/].
531        *
532        *   We could sort the actors_that_ran array completely so that we can describe the order in which simcalls are
533        *   handled (like "according to the PID of issuer"), but it's not mandatory (order is fixed already even if
534        *   unfriendly).
535        *   That would thus be a pure waste of time.
536        */
537
538       for (auto const& actor : actors_that_ran_) {
539         if (actor->simcall_.call_ != simix::Simcall::NONE) {
540           actor->simcall_handle(0);
541         }
542       }
543
544       execute_tasks();
545       do {
546         wake_all_waiting_actors();
547       } while (execute_tasks());
548
549       /* If only daemon actors remain, cancel their actions, mark them to die and reschedule them */
550       if (actor_list_.size() == daemons_.size())
551         for (auto const& dmon : daemons_) {
552           XBT_DEBUG("Kill %s", dmon->get_cname());
553           maestro_->kill(dmon);
554         }
555     }
556
557     time = timer::Timer::next();
558     if (time > -1.0 || not actor_list_.empty()) {
559       XBT_DEBUG("Calling surf_solve");
560       time = surf_solve(time);
561       XBT_DEBUG("Moving time ahead : %g", time);
562     }
563
564     /* Notify all the hosts that have failed */
565     /* FIXME: iterate through the list of failed host and mark each of them */
566     /* as failed. On each host, signal all the running actors with host_fail */
567
568     // Execute timers and tasks until there isn't anything to be done:
569     bool again = false;
570     do {
571       again = timer::Timer::execute_all();
572       if (execute_tasks())
573         again = true;
574       wake_all_waiting_actors();
575     } while (again);
576
577     /* Clean actors to destroy */
578     empty_trash();
579
580     XBT_DEBUG("### time %f, #actors %zu, #to_run %zu", time, actor_list_.size(), actors_to_run_.size());
581
582     if (time < 0. && actors_to_run_.empty() && not actor_list_.empty()) {
583       if (actor_list_.size() <= daemons_.size()) {
584         XBT_CRITICAL("Oops! Daemon actors cannot do any blocking activity (communications, synchronization, etc) "
585                      "once the simulation is over. Please fix your on_exit() functions.");
586       } else {
587         XBT_CRITICAL("Oops! Deadlock or code not perfectly clean.");
588       }
589       display_all_actor_status();
590       simgrid::s4u::Engine::on_deadlock();
591       for (auto const& kv : actor_list_) {
592         XBT_DEBUG("Kill %s", kv.second->get_cname());
593         maestro_->kill(kv.second);
594       }
595     }
596   } while (time > -1.0 || has_actors_to_run());
597
598   if (not actor_list_.empty())
599     THROW_IMPOSSIBLE;
600
601   simgrid::s4u::Engine::on_simulation_end();
602 }
603 } // namespace kernel
604 } // namespace simgrid