Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Use the actual heap size when testing if an address is in the heap in mc_compare
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 16 May 2014 07:53:46 +0000 (09:53 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 16 May 2014 09:24:57 +0000 (11:24 +0200)
src/mc/mc_compare.c

index 5a6eb58..981c98c 100644 (file)
@@ -9,6 +9,7 @@
 #include "mc_private.h"
 
 #include "xbt/mmalloc.h"
+#include "xbt/mmalloc/mmprivate.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_compare, mc,
                                 "Logging specific to mc_compare");
@@ -99,6 +100,13 @@ static int add_compared_pointers(void *p1, void *p2){
   return 1;
 }
 
+inline static void* get_heap_end(mc_snapshot_t snapshot) {
+  if(snapshot==NULL)
+    xbt_die("snapshot is NULL");
+  xbt_mheap_t heap = (xbt_mheap_t)snapshot->regions[0]->data;
+  return heap->breakval;
+}
+
 static int compare_areas_with_type(void *area1, void *area2, mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, dw_type_t type, int region_size, int region_type, void *start_data, int pointer_level){
 
   unsigned int cursor = 0;
@@ -179,10 +187,10 @@ static int compare_areas_with_type(void *area1, void *area2, mc_snapshot_t snaps
       // * a pointer leads to the read-only segment of the current object;
       // * a pointer lead to a different ELF object.
 
-      // The pointers are both in the heap:
-      if(addr_pointed1 > std_heap && (char *)addr_pointed1 < (char*) std_heap + STD_HEAP_SIZE){
-        if(!(addr_pointed2 > std_heap && (char *)addr_pointed2 < (char*) std_heap + STD_HEAP_SIZE))
+      if(addr_pointed1 > std_heap && addr_pointed1 < get_heap_end(snapshot1)){
+        if(!(addr_pointed2 > std_heap && addr_pointed2 < get_heap_end(snapshot2)))
           return 1;
+        // The pointers are both in the heap:
         return compare_heap_area(addr_pointed1, addr_pointed2, snapshot1, snapshot2, NULL, type->subtype, pointer_level);
       }