Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Actually, read()=0 is not an issue in the AppSide
[simgrid.git] / src / mc / remote / AppSide.cpp
index 7c970ff..447f7db 100644 (file)
@@ -147,8 +147,9 @@ void AppSide::handle_finalize(const s_mc_message_int_t* msg) const
   if (terminate_asap)
     ::_Exit(0);
 }
-void AppSide::handle_initial_addresses() const
+void AppSide::handle_initial_addresses()
 {
+  this->need_memory_info_                       = true;
   s_mc_message_initial_addresses_reply_t answer = {};
   answer.type                                   = MessageType::INITIAL_ADDRESSES_REPLY;
   answer.mmalloc_default_mdp                    = mmalloc_get_current_heap();
@@ -237,7 +238,7 @@ void AppSide::handle_actors_maxpid() const
   xbt_assert(received_size == sizeof(_type_), "Unexpected size for " _name_ " (%zd != %zu)", received_size,            \
              sizeof(_type_))
 
-void AppSide::handle_messages() const
+void AppSide::handle_messages()
 {
   while (true) { // Until we get a CONTINUE message
     XBT_DEBUG("Waiting messages from model-checker");
@@ -245,6 +246,10 @@ void AppSide::handle_messages() const
     std::array<char, MC_MESSAGE_LENGTH> message_buffer;
     ssize_t received_size = channel_.receive(message_buffer.data(), message_buffer.size());
 
+    if (received_size == 0) {
+      XBT_DEBUG("Socket closed on the Checker side, bailing out.");
+      ::_Exit(0); // Nobody's listening to that process anymore => exit as quickly as possible.
+    }
     xbt_assert(received_size >= 0, "Could not receive commands from the model-checker");
     xbt_assert(static_cast<size_t>(received_size) >= sizeof(s_mc_message_t), "Cannot handle short message (size=%zd)",
                received_size);
@@ -292,7 +297,7 @@ void AppSide::handle_messages() const
   }
 }
 
-void AppSide::main_loop() const
+void AppSide::main_loop()
 {
   simgrid::mc::processes_time.resize(simgrid::kernel::actor::ActorImpl::get_maxpid());
   MC_ignore_heap(simgrid::mc::processes_time.data(),
@@ -308,7 +313,7 @@ void AppSide::main_loop() const
   }
 }
 
-void AppSide::report_assertion_failure() const
+void AppSide::report_assertion_failure()
 {
   xbt_assert(channel_.send(MessageType::ASSERTION_FAILED) == 0, "Could not send assertion to model-checker");
   this->handle_messages();
@@ -363,8 +368,10 @@ void AppSide::unignore_heap(void* address, std::size_t size) const
 
 void AppSide::declare_symbol(const char* name, int* value) const
 {
-  if (not MC_is_active() || not need_memory_info_)
+  if (not MC_is_active() || not need_memory_info_) {
+    XBT_CRITICAL("Ignore AppSide::declare_symbol(%s)", name);
     return;
+  }
 
   s_mc_message_register_symbol_t message = {};
   message.type = MessageType::REGISTER_SYMBOL;