Logo AND Algorithmique Numérique Distribuée

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