Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Ahem. You mean I need to actually compile with MC after moving files?
[simgrid.git] / src / kernel / context / ContextSwapped.cpp
index ccc0420..9263c63 100644 (file)
@@ -6,8 +6,8 @@
 #include "simgrid/Exception.hpp"
 #include "simgrid/modelchecker.h"
 #include "src/internal_config.h"
+#include "src/kernel/actor/ActorImpl.hpp"
 #include "src/kernel/context/context_private.hpp"
-#include "src/simix/ActorImpl.hpp"
 #include "src/simix/smx_private.hpp"
 #include "xbt/parmap.hpp"
 
@@ -52,6 +52,7 @@ SwappedContext::SwappedContext(std::function<void()>&& code, smx_actor_t actor,
     factory_->workers_context_[0] = this;
 
   if (has_code()) {
+    xbt_assert((smx_context_stack_size & 0xf) == 0, "smx_context_stack_size should be multiple of 16");
     if (smx_context_guard_size > 0 && not MC_is_active()) {
 
 #if !defined(PTH_STACKGROWTH) || (PTH_STACKGROWTH != -1)
@@ -85,8 +86,9 @@ SwappedContext::SwappedContext(std::function<void()>&& code, smx_actor_t actor,
             "Failed to protect stack: %s.\n"
             "If you are running a lot of actors, you may be exceeding the amount of mappings allowed per process.\n"
             "On Linux systems, change this value with sudo sysctl -w vm.max_map_count=newvalue (default value: 65536)\n"
-            "Please see http://simgrid.gforge.inria.fr/simgrid/latest/doc/html/options.html#options_virt for more "
-            "info.",
+            "Please see "
+            "https://simgrid.org/doc/latest/Configuring_SimGrid.html#configuring-the-user-code-virtualization for more "
+            "information.",
             strerror(errno));
         /* This is fatal. We are going to fail at some point when we try reusing this. */
       }
@@ -97,13 +99,13 @@ SwappedContext::SwappedContext(std::function<void()>&& code, smx_actor_t actor,
     }
 
 #if PTH_STACKGROWTH == -1
-    ASAN_ONLY(this->asan_stack_ = this->stack_ + smx_context_usable_stack_size);
+    ASAN_ONLY(this->asan_stack_ = this->stack_ + smx_context_stack_size);
 #else
     ASAN_ONLY(this->asan_stack_ = this->stack_);
 #endif
 #if HAVE_VALGRIND_H
-    unsigned int valgrind_stack_id = VALGRIND_STACK_REGISTER(this->stack_, this->stack_ + smx_context_stack_size);
-    memcpy(this->stack_ + smx_context_usable_stack_size, &valgrind_stack_id, sizeof valgrind_stack_id);
+    if (RUNNING_ON_VALGRIND)
+      this->valgrind_stack_id_ = VALGRIND_STACK_REGISTER(this->stack_, this->stack_ + smx_context_stack_size);
 #endif
   }
 }
@@ -114,9 +116,8 @@ SwappedContext::~SwappedContext()
     return;
 
 #if HAVE_VALGRIND_H
-  unsigned int valgrind_stack_id;
-  memcpy(&valgrind_stack_id, stack_ + smx_context_usable_stack_size, sizeof valgrind_stack_id);
-  VALGRIND_STACK_DEREGISTER(valgrind_stack_id);
+  if (RUNNING_ON_VALGRIND)
+    VALGRIND_STACK_DEREGISTER(valgrind_stack_id_);
 #endif
 
 #ifndef _WIN32