Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Enforce some assumption about the relationship of the compared areas in compare_...
authorGabriel Corona <gabriel.corona@loria.fr>
Mon, 20 Jan 2014 14:23:54 +0000 (15:23 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 31 Jan 2014 11:00:27 +0000 (12:00 +0100)
Compare_areas_with_type expects that either :

 * both area are in the heap;
 * both area are in the current segment R/W segment.

Otherwise, it falls back to comparing pointers.

Changes to code to fail if both areas are not in the same segment

src/mc/mc_compare.c

index 12390fb..6dda53a 100644 (file)
@@ -207,14 +207,16 @@ static int compare_areas_with_type(void *area1, void *area2, xbt_dict_t types, x
       // * 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
-        && addr_pointed2 > std_heap && (char *)addr_pointed2 < (char*) std_heap + STD_HEAP_SIZE){
+      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))
+          xbt_die("Die");
         return compare_heap_area(addr_pointed1, addr_pointed2, NULL, types, other_types, type->dw_type_id, pointer_level); 
       }
 
       // The pointers are both in the current object R/W segment:
-      else if(addr_pointed1 > start_data && (char*)addr_pointed1 <= (char *)start_data + region_size
-        && addr_pointed2 > start_data && (char*)addr_pointed2 <= (char *)start_data + region_size){
+      else if(addr_pointed1 > start_data && (char*)addr_pointed1 <= (char *)start_data + region_size){
+        if(!(addr_pointed2 > start_data && (char*)addr_pointed2 <= (char *)start_data + region_size))
+          xbt_die("Die");
         if(type->dw_type_id == NULL)
           return  (addr_pointed1 != addr_pointed2);
         else