]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
When the leak checker finds overlapping blocks report the details
authorTom Hughes <tom@compton.nu>
Fri, 18 Jul 2008 08:48:04 +0000 (08:48 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 18 Jul 2008 08:48:04 +0000 (08:48 +0000)
before asserting.

Based on patch from John Reiser <jreiser@BitWagon.com>.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8441

memcheck/mc_leakcheck.c

index 3a7fa65eaf6793fd3cd5887b5fae5ec98b1be36c..d9dc42f2d38843eef65abf07e92a554814b8721d 100644 (file)
@@ -704,14 +704,20 @@ void MC_(do_detect_memory_leaks) (
       to screw up is to use VALGRIND_MALLOCLIKE_BLOCK for stack
       locations; again nonsensical. */
    for (i = 0; i < lc_n_shadows-1; i++) {
-      tl_assert( /* normal case - no overlap */
-                 (lc_shadows[i]->data + lc_shadows[i]->szB
-                  <= lc_shadows[i+1]->data )
-                 ||
-                 /* degenerate case: exact duplicates */
-                 (lc_shadows[i]->data == lc_shadows[i+1]->data
-                  && lc_shadows[i]->szB == lc_shadows[i+1]->szB)
-               );
+      Bool nonsense_overlap = ! (
+            /* normal case - no overlap */
+            (lc_shadows[i]->data + lc_shadows[i]->szB <= lc_shadows[i+1]->data)
+         ||
+            /* degenerate case: exact duplicates */
+              (lc_shadows[i]->data == lc_shadows[i+1]->data
+            && lc_shadows[i]->szB == lc_shadows[i+1]->szB)
+         );
+      if (nonsense_overlap) {
+         VG_(message)(Vg_UserMsg, "Block [0x%lx, 0x%lx) overlaps with block [0x%lx, 0x%lx)",
+                      lc_shadows[   i]->data, (lc_shadows[   i]->data + lc_shadows[   i]->szB),
+                      lc_shadows[1+ i]->data, (lc_shadows[1+ i]->data + lc_shadows[1+ i]->szB) );
+      }
+      tl_assert (!nonsense_overlap);
    }
 
    if (lc_n_shadows == 0) {