Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC replay: check whether there is a deadlock after running the trace
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 31 Oct 2022 23:35:54 +0000 (00:35 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 31 Oct 2022 23:45:41 +0000 (00:45 +0100)
src/mc/mc_record.cpp
teshsuite/mc/random-bug/random-bug-replay.tesh

index 6b9cd75..3b35ead 100644 (file)
@@ -23,9 +23,10 @@ namespace simgrid::mc {
 void RecordTrace::replay() const
 {
   simgrid::mc::execute_actors();
+  auto* engine = kernel::EngineImpl::get_instance();
 
   for (const simgrid::mc::Transition* transition : transitions_) {
-    kernel::actor::ActorImpl* actor = kernel::EngineImpl::get_instance()->get_actor_by_pid(transition->aid_);
+    kernel::actor::ActorImpl* actor = engine->get_actor_by_pid(transition->aid_);
     xbt_assert(actor != nullptr, "Unexpected actor (id:%ld).", transition->aid_);
     const kernel::actor::Simcall* simcall = &(actor->simcall_);
     xbt_assert(simgrid::mc::request_is_visible(simcall), "Simcall %s of actor %s is not visible.", simcall->get_cname(),
@@ -43,6 +44,17 @@ void RecordTrace::replay() const
     simcall->issuer_->simcall_handle(transition->times_considered_);
     simgrid::mc::execute_actors();
   }
+
+  const auto& actor_list = engine->get_actor_list();
+  if (actor_list.empty()) {
+    XBT_INFO("The replay of the trace is complete. The application is terminating.");
+  } else if (std::none_of(begin(actor_list), end(actor_list),
+                          [](const auto& kv) { return mc::actor_is_enabled(kv.second); })) {
+    XBT_INFO("The replay of the trace is complete. DEADLOCK detected.");
+    engine->display_all_actor_status();
+  } else {
+    XBT_INFO("The replay of the trace is complete. The application could run further.");
+  }
 }
 
 void simgrid::mc::RecordTrace::replay(const std::string& path_string)
index df08557..c32150f 100644 (file)
@@ -3,6 +3,7 @@ $ ${bindir:=.}/random-bug printf ${platfdir}/small_platform.xml  --log=xbt_cfg.t
 > [  0.000000] (0:maestro@) Behavior: printf
 > [  0.000000] (0:maestro@) path=1/3;1/4
 > [  0.000000] (1:app@Fafard) Error reached
+> [  0.000000] (0:maestro@) The replay of the trace is complete. The application is terminating.
 
 # Behavior: assert does not have the same output within and without MC, so don't test it here. That's already covered with the other ones