]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
In the leak checker, don't assert when there are multiple identical
authorJulian Seward <jseward@acm.org>
Thu, 29 May 2008 12:23:24 +0000 (12:23 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 29 May 2008 12:23:24 +0000 (12:23 +0000)
blocks in the lc_shadows array.  Such a situation could arise from
incorrect use of VALGRIND_MALLOCLIKE_BLOCK, and has been observed to
cause assertion failures for some runs of Wine on Valgrind.

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

memcheck/mc_leakcheck.c

index c838d3c1b4dd7c4c9ef5873c5dd630f67a0be6e9..a8af9ff05b113bea8b466b8355a3a910d0374e61 100644 (file)
@@ -694,10 +694,22 @@ void MC_(do_detect_memory_leaks) (
       tl_assert( lc_shadows[i]->data <= lc_shadows[i+1]->data);
    }
 
-   /* Sanity check -- make sure they don't overlap */
+   /* Sanity check -- make sure they don't overlap.  But do allow
+      exact duplicates.  If this assertion fails, it may mean that the
+      application has done something stupid with
+      VALGRIND_MALLOCLIKE_BLOCK client requests, specifically, has
+      made overlapping requests (which are nonsensical).  Another way
+      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( lc_shadows[i]->data + lc_shadows[i]->szB
-                 <= lc_shadows[i+1]->data );
+      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)
+               );
    }
 
    if (lc_n_shadows == 0) {