Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Fix out of range error in the binary search implementation
[simgrid.git] / src / mc / mc_object_info.cpp
index 11817a2..46c4630 100644 (file)
@@ -108,7 +108,7 @@ void *ObjectInformation::base_address() const
 }
 
 /* Find a function by instruction pointer */
-mc_frame_t ObjectInformation::find_function(const void *ip) const
+simgrid::mc::Frame* ObjectInformation::find_function(const void *ip) const
 {
   /* This is implemented by binary search on a sorted array.
    *
@@ -130,7 +130,7 @@ mc_frame_t ObjectInformation::find_function(const void *ip) const
     int k = i + ((j - i) / 2);
     if (ip < base[k].low_pc)
       j = k - 1;
-    else if (k <= j && ip >= base[k + 1].low_pc)
+    else if (k < j && ip >= base[k + 1].low_pc)
       i = k + 1;
     else if (ip < base[k].function->high_pc)
       return base[k].function;