Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Fix MC cross-process memory access
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 12 Feb 2016 15:41:08 +0000 (16:41 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 12 Feb 2016 15:43:16 +0000 (16:43 +0100)
"[mc] Fix testall" broke the MC on syustems where you cannot read
another process memory without ptracing/stopping it first.

src/mc/ModelChecker.cpp
src/mc/ModelChecker.hpp
src/mc/mc_snapshot.cpp

index be6f39b..4411458 100644 (file)
@@ -54,7 +54,7 @@ ModelChecker::ModelChecker(pid_t pid, int socket) :
   page_store_(500),
   parent_snapshot_(nullptr)
 {
-  process_ = std::unique_ptr<Process>(new Process(pid_, socket_));
+
 }
 
 ModelChecker::~ModelChecker()
@@ -74,6 +74,14 @@ const char* ModelChecker::get_host_name(const char* hostname)
   return elt->key;
 }
 
+// HACK, for the unit test only
+void ModelChecker::init_process()
+{
+  // TODO, avoid direct dependency on sg_cfg
+  process_ = std::unique_ptr<Process>(new Process(pid_, socket_));
+  process_->privatized(sg_cfg_get_boolean("smpi/privatize_global_variables"));
+}
+
 void ModelChecker::start()
 {
   // Block SIGCHLD (this will be handled with accept/signalfd):
@@ -110,9 +118,7 @@ void ModelChecker::start()
   if (res < 0 || !WIFSTOPPED(status) || WSTOPSIG(status) != SIGSTOP)
     xbt_die("Could not wait model-checked process");
 
-
-  // TODO, avoid direct dependency on sg_cfg
-  process_->privatized(sg_cfg_get_boolean("smpi/privatize_global_variables"));
+  this->init_process();
 
   /* Initialize statistics */
   mc_stats = xbt_new0(s_mc_stats_t, 1);
index 75b2f5d..a90e1b4 100644 (file)
@@ -62,6 +62,7 @@ public:
   }
 
   void start();
+  void init_process();
   void shutdown();
   void resume(simgrid::mc::Process& process);
   void loop();
index 2d534f5..a1ea070 100644 (file)
@@ -233,6 +233,7 @@ static void test_snapshot(bool sparse_checkpoint) {
   xbt_assert(xbt_pagesize == getpagesize());
   xbt_assert(1 << xbt_pagebits == xbt_pagesize);
   mc_model_checker = new ::simgrid::mc::ModelChecker(getpid(), -1);
+  mc_model_checker->init_process();
 
   for(int n=1; n!=256; ++n) {