Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Display a nice error message when ptrace is not usable
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 3 Mar 2022 11:12:59 +0000 (12:12 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 3 Mar 2022 11:30:36 +0000 (12:30 +0100)
Fixes https://framagit.org/simgrid/simgrid/-/issues/57

ChangeLog
src/mc/ModelChecker.cpp

index 3453aea..730556e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@ MC:
    See CommunicationDeterminism for an example.
  - Support mutex in DPOR reduction
  - Seems to work on Arm64 architectures too.
+ - Display a nice error message when ptrace is not usable.
 
 SMPI:
  - fix for FG#100 by ensuring small asynchronous messages never overtake larger
@@ -24,6 +25,7 @@ XBT:
 
 Fixed bugs (FG#.. -> FramaGit bugs; FG!.. -> FG merge requests)
  (FG: issues on Framagit; GH: issues on GitHub)
+ - FG#57: Mc SimGrid should test whether ptrace is usable
  - FG#100: [SMPI] Order of the message matching is not guaranteed
  - FG#101: LGPL 2.1 is deprecated license
  - GH#151: Missing mutexes for DPOR.
index 75024f6..cf46e68 100644 (file)
@@ -74,6 +74,7 @@ void ModelChecker::start()
 
   setup_ignore();
 
+  errno = 0;
 #ifdef __linux__
   ptrace(PTRACE_SETOPTIONS, pid, nullptr, PTRACE_O_TRACEEXIT);
   ptrace(PTRACE_CONT, pid, 0, 0);
@@ -82,6 +83,11 @@ void ModelChecker::start()
 #else
 # error "no ptrace equivalent coded for this platform"
 #endif
+  xbt_assert(errno == 0,
+             "Ptrace does not seem to be usable in your setup (errno: %d). "
+             "If you run from within a docker, adding `--cap-add SYS_PTRACE` to the docker line may help. "
+             "If it does not help, please report this bug.",
+             errno);
 }
 
 static constexpr auto ignored_local_variables = {