From: Gabriel Corona Date: Mon, 20 Jan 2014 12:06:07 +0000 (+0100) Subject: [mc] In compare_global_variables only compare values in the R/W segment X-Git-Tag: v3_11~199^2~2^2~26^2~11 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a914d4f8177b28e1217d3bbf417fb7f054a38356 [mc] In compare_global_variables only compare values in the R/W segment The algorithme is only relevant if the variable is in the R/W segment otherwise the resulting pointer will be broken and might result in a SIGSEV. This happen if we try to compare a pointer on the .rodata (such as __FUNCTION__). Values are supposed to be constant and we do not expect to find pointers to something which is not reachable by the global variables. --- diff --git a/src/mc/mc_compare.c b/src/mc/mc_compare.c index 4eae390ee8..fad33714ea 100644 --- a/src/mc/mc_compare.c +++ b/src/mc/mc_compare.c @@ -268,10 +268,14 @@ static int compare_global_variables(int region_type, mc_mem_region_t r1, mc_mem_ xbt_dynar_foreach(variables, cursor, current_var){ - if(region_type == 2) - offset = (char *)current_var->address.address - (char *)start_data_binary; - else - offset = (char *)current_var->address.address - (char *)start_data_libsimgrid; + // If the variable is not in this object, skip it: + // We do not expect to find a pointer to something which is not reachable + // by the global variables. + if((char*) current_var->address.address < (char*) object_info->start_rw + || (char*) current_var->address.address > (char*) object_info->end_rw) + continue; + + offset = (char *)current_var->address.address - (char *)object_info->start_rw; res = compare_areas_with_type((char *)r1->data + offset, (char *)r2->data + offset, types, other_types, current_var->type_origin, r1->size, region_type, start_data, 0); if(res == 1){