Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sthread/ObjectAccess: bug fix + report when more than one location 'owns' an object
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 25 Oct 2023 16:09:42 +0000 (18:09 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 25 Oct 2023 16:11:45 +0000 (18:11 +0200)
src/sthread/ObjectAccess.cpp

index 7e3e6d4..bc5415b 100644 (file)
@@ -86,10 +86,17 @@ int sthread_access_begin(void* objaddr, const char* objname, const char* file, i
         auto* ownership = get_owner(objaddr);
         if (ownership->owner == self) {
           ownership->recursive_depth++;
+          return true;
         } else if (ownership->owner != nullptr) {
           auto msg = std::string("Unprotected concurent access to ") + objname + ": " + ownership->owner->get_name();
-          if (not xbt_log_no_loc)
+          if (not xbt_log_no_loc) {
             msg += simgrid::xbt::string_printf(" at %s:%d", ownership->file, ownership->line);
+            if (ownership->recursive_depth > 1)
+              msg += simgrid::xbt::string_printf(" (and %d other locations)", ownership->recursive_depth - 1);
+          } else {
+            msg += simgrid::xbt::string_printf(" from %d locations (remove --log=no_loc for details)",
+                                               ownership->recursive_depth);
+          }
           msg += " vs " + self->get_name();
           if (xbt_log_no_loc)
             msg += std::string(" (locations hidden because of --log=no_loc).");