]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add a new heuristic 'length64' to detect interior pointers
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 21 Jul 2014 19:55:11 +0000 (19:55 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 21 Jul 2014 19:55:11 +0000 (19:55 +0000)
pointing at offset 64bit of a block, when the first 8 bytes contains
the block size - 8. This is e.g. used by sqlite3MemMalloc.

Patch by Matthias Schwarzott (with small modif)

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

NEWS
gdbserver_tests/mchelp.stdoutB.exp
memcheck/docs/mc-manual.xml
memcheck/mc_include.h
memcheck/mc_leakcheck.c
memcheck/mc_main.c
memcheck/tests/leak_cpp_interior.cpp
memcheck/tests/leak_cpp_interior.stderr.exp
memcheck/tests/leak_cpp_interior.stderr.exp-64bit
memcheck/tests/leak_cpp_interior.vgtest

diff --git a/NEWS b/NEWS
index 00469881fcb1e4eb0e61a87eb698b1d0dcbf1db0..22eb415002d41ab1247368360055f56de10515fc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,9 @@ Release 3.10.0 (?? ?????? 201?)
   - new client requests 
     VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE and
     VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE
+  - new leak check heuristic 'length64' to detect interior pointers
+    pointing at offset 64bit of a block, when the first 8 bytes contains
+    the block size - 8. This is e.g. used by sqlite3MemMalloc.
 
 * Helgrind:
   - Helgrind GDB server monitor command 'info locks' giving
@@ -184,6 +187,7 @@ where XXXXXX is the bug number as listed below.
 336957  Add a section about the Solaris/illumos port on the webpage
 337094  ifunc wrapper is broken on ppc64
 337285  fcntl commands F_OFD_SETLK, F_OFD_SETLKW, and F_OFD_GETLK not supported
+337528  leak check heuristic for block prefixed by length as 64bit number
 n-i-bz  Fix KVM_CREATE_IRQCHIP ioctl handling
 n-i-bz  s390x: Fix memory corruption for multithreaded applications
 n-i-bz  vex arm->IR: allow PC as basereg in some LDRD cases
index 0143bd0b44a70596d27b010233ca95eef4eba0fb..6e6ab2635b03ba9215203f38f95ce4882c6e554a 100644 (file)
@@ -31,7 +31,8 @@ memcheck monitor commands:
                 [unlimited*|limited <max_loss_records_output>]
             * = defaults
        where kind is one of definite indirect possible reachable all none
-       where heur is one of stdstring newarray multipleinheritance all none*
+       where heur is one of stdstring length64 newarray
+                               multipleinheritance all none*
         Examples: leak_check
                   leak_check summary any
                   leak_check full kinds indirect,possible
@@ -90,7 +91,8 @@ memcheck monitor commands:
                 [unlimited*|limited <max_loss_records_output>]
             * = defaults
        where kind is one of definite indirect possible reachable all none
-       where heur is one of stdstring newarray multipleinheritance all none*
+       where heur is one of stdstring length64 newarray
+                               multipleinheritance all none*
         Examples: leak_check
                   leak_check summary any
                   leak_check full kinds indirect,possible
index 66a1eb38b1d064a9bf1e5222d93d7d67a51b8df2..887e82d53dfa431a14e440a6aa70d07dd1f89494 100644 (file)
@@ -461,6 +461,21 @@ several ways we know of that an interior-pointer can occur:</para>
     a coincidence.</para>
   </listitem>
     
+  <listitem>
+    <para>It might be a pointer to the inner char array of a C++
+    <computeroutput>std::string</computeroutput>.  For example, some
+    compilers add 3 words at the beginning of the std::string to
+    store the length, the capacity and a reference count before the
+    memory containing the array of characters. They return a pointer
+    just after these 3 words, pointing at the char array.</para>
+  </listitem>
+
+  <listitem>
+    <para>Some code might allocate a block of memory, and use the first 8
+    bytes to store (block size - 8) as a 64bit number.
+    <computeroutput>sqlite3MemMalloc</computeroutput> does this.</para>
+  </listitem>
+
   <listitem>
     <para>It might be a pointer to an array of C++ objects (which possess
     destructors) allocated with <computeroutput>new[]</computeroutput>.  In
@@ -471,15 +486,6 @@ several ways we know of that an interior-pointer can occur:</para>
     page</ulink> for more information.</para>
   </listitem>
 
-  <listitem>
-    <para>It might be a pointer to the inner char array of a C++
-    <computeroutput>std::string</computeroutput>.  For example, some
-    compilers add 3 words at the beginning of the std::string to
-    store the length, the capacity and a reference count before the
-    memory containing the array of characters. They return a pointer
-    just after these 3 words, pointing at the char array.</para>
-  </listitem>
-
   <listitem>
     <para>It might be a pointer to an inner part of a C++ object using
     multiple inheritance. </para>
@@ -488,9 +494,10 @@ several ways we know of that an interior-pointer can occur:</para>
 
 <para>You can optionally activate heuristics to use during the leak
 search to detect the interior pointers corresponding to
-the <computeroutput>newarray</computeroutput>,
-<computeroutput>stdstring</computeroutput> and
-<computeroutput>multipleinheritance</computeroutput> cases. If the
+the <computeroutput>stdstring</computeroutput>,
+<computeroutput>length64</computeroutput>,
+<computeroutput>newarray</computeroutput>
+and <computeroutput>multipleinheritance</computeroutput> cases. If the
 heuristic detects that an interior pointer corresponds to such a case,
 the block will be considered as reachable by the interior
 pointer. In other words, the interior pointer will be treated
@@ -599,8 +606,8 @@ LEAK SUMMARY:
 
 <para>If heuristics have been used to consider some blocks as
 reachable, the leak summary details the heuristically reachable subset
-of 'still reachable:' per heuristic. In the below example, of the 79
-bytes still reachable, 71 bytes (56+7+8) have been considered
+of 'still reachable:' per heuristic. In the below example, of the 95
+bytes still reachable, 87 bytes (56+7+8+16) have been considered
 heuristically reachable.
 </para>
 
@@ -609,9 +616,10 @@ LEAK SUMMARY:
    definitely lost: 4 bytes in 1 blocks
    indirectly lost: 0 bytes in 0 blocks
      possibly lost: 0 bytes in 0 blocks
-   still reachable: 79 bytes in 5 blocks
+   still reachable: 95 bytes in 6 blocks
                       of which reachable via heuristic:
                         stdstring          : 56 bytes in 2 blocks
+                        length64           : 16 bytes in 1 blocks
                         newarray           : 7 bytes in 1 blocks
                         multipleinheritance: 8 bytes in 1 blocks
         suppressed: 0 bytes in 0 blocks
@@ -810,13 +818,13 @@ is <option>--errors-for-leak-kinds=definite,possible</option>
 
       <itemizedlist>
         <listitem><para>a comma separated list of one or more of
-            <option>stdstring newarray multipleinheritance</option>.</para>
+            <option>stdstring length64 newarray multipleinheritance</option>.</para>
         </listitem>
           
         <listitem><para><option>all</option> to activate the complete set of
             heuristics.
             It is equivalent to
-            <option>--leak-check-heuristics=stdstring,newarray,multipleinheritance</option>.</para>
+            <option>--leak-check-heuristics=stdstring,length64,newarray,multipleinheritance</option>.</para>
         </listitem>
         
         <listitem><para><option>none</option> for the empty set.</para>
index 425d23380b747fecf94190ec70e3b49b7e8eab50..f53f3db4c331e967ccbdf08e827cf4cd9af00875 100644 (file)
@@ -513,18 +513,23 @@ typedef
       LchStdString           =1,
       // Consider interior pointer pointing at the array of char in a
       // std::string as reachable.
-      LchNewArray            =2,
+      LchLength64            =2,
+      // Consider interior pointer pointing at offset 64bit of a block as
+      // reachable, when the first 8 bytes contains the block size - 8.
+      // Such length+interior pointers are used by e.g. sqlite3MemMalloc.
+      // On 64bit platforms LchNewArray will also match these blocks.
+      LchNewArray            =3,
       // Consider interior pointer pointing at second word of a new[] array as
       // reachable. Such interior pointers are used for arrays whose elements
       // have a destructor.
-      LchMultipleInheritance =3,
+      LchMultipleInheritance =4,
       // Conside interior pointer pointing just after what looks a vtable
       // as reachable.
   }
   LeakCheckHeuristic;
 
 // Nr of heuristics, including the LchNone heuristic.
-#define N_LEAK_CHECK_HEURISTICS 4
+#define N_LEAK_CHECK_HEURISTICS 5
 
 // Build mask to check or set Heuristic h membership
 #define H2S(h) (1 << (h))
@@ -532,7 +537,8 @@ typedef
 #define HiS(h,s) ((s) & R2S(h))
 // A set with all Heuristics:
 #define HallS \
-   (H2S(LchStdString) | H2S(LchNewArray) | H2S(LchMultipleInheritance))
+   (H2S(LchStdString) | H2S(LchLength64) | H2S(LchNewArray) | \
+       H2S(LchMultipleInheritance))
 
 /* Heuristics set to use for the leak search.
    Default : no heuristic. */
index 670d89f986ea75f37aaee5840df7787b160e9b62..cb8abd162f215dba31ee0b62ed46868e4583b874 100644 (file)
@@ -594,6 +594,7 @@ static const HChar* pp_heuristic(LeakCheckHeuristic h)
    switch(h) {
    case LchNone:                return "none";
    case LchStdString:           return "stdstring";
+   case LchLength64:            return "length64";
    case LchNewArray:            return "newarray";
    case LchMultipleInheritance: return "multipleinheritance";
    default:                     return "???invalid heuristic???";
@@ -672,6 +673,16 @@ static Bool aligned_ptr_above_page0_is_vtable_addr(Addr ptr)
    return False;
 }
 
+// true if a is properly aligned and points to 64bits of valid memory
+static Bool is_valid_aligned_ULong ( Addr a )
+{
+   if (sizeof(Word) == 8)
+      return MC_(is_valid_aligned_word)(a);
+
+   return MC_(is_valid_aligned_word)(a)
+      && MC_(is_valid_aligned_word)(a + 4);
+}
+
 // If ch is heuristically reachable via an heuristic member of heur_set,
 // returns this heuristic.
 // If ch cannot be considered reachable using one of these heuristics,
@@ -712,6 +723,23 @@ static LeakCheckHeuristic heuristic_reachedness (Addr ptr,
       }
    }
 
+   if (HiS(LchLength64, heur_set)) {
+      // Detects inner pointers that point at 64bit offset (8 bytes) into a
+      // block following the length of the remaining as 64bit number 
+      // (=total block size - 8).
+      // This is used e.g. by sqlite for tracking the total size of allocated
+      // memory.
+      // Note that on 64bit platforms, a block matching LchLength64 will
+      // also be matched by LchNewArray.
+      if ( ptr == ch->data + sizeof(ULong)
+          && is_valid_aligned_ULong(ch->data)) {
+         const ULong size = *((ULong*)ch->data);
+         if (size > 0 && (ch->szB - sizeof(ULong)) == size) {
+            return LchLength64;
+         }
+      }
+   }
+
    if (HiS(LchNewArray, heur_set)) {
       // Detects inner pointers at second word of new[] array, following
       // a plausible nr of elements.
@@ -1058,7 +1086,7 @@ lc_scan_memory(Addr start, SizeT len, Bool is_prior_definite,
                   MC_(pp_describe_addr) (ptr);
                   if (lc_is_a_chunk_ptr(addr, &ch_no, &ch, &ex) ) {
                      Int h;
-                     for (h = LchStdString; h <= LchMultipleInheritance; h++) {
+                     for (h = LchStdString; h < N_LEAK_CHECK_HEURISTICS; h++) {
                         if (heuristic_reachedness(addr, ch, ex, H2S(h)) == h) {
                            VG_(umsg)("block at %#lx considered reachable "
                                      "by ptr %#lx using %s heuristic\n",
index e51c05fa0c2ef57b685cf69a609beb42b1ea5993..7a8e9b71ffd025c6cd85e68826d822ebb311457f 100644 (file)
@@ -5197,8 +5197,9 @@ Int           MC_(clo_mc_level)               = 2;
 
 static Bool MC_(parse_leak_heuristics) ( const HChar *str0, UInt *lhs )
 {
-   return  VG_(parse_enum_set) ("-,stdstring,newarray,multipleinheritance",
-                                str0, lhs);
+   return 
+      VG_(parse_enum_set) ("-,stdstring,length64,newarray,multipleinheritance",
+                           str0, lhs);
 }
 
 
@@ -5370,7 +5371,8 @@ static void mc_print_usage(void)
 "        where kind is one of definite indirect possible reachable all none\n"
 "    --leak-check-heuristics=heur1,heur2,... which heuristics to use for\n"
 "        improving leak search false positive [none]\n"
-"        where heur is one of stdstring newarray multipleinheritance all none\n"
+"        where heur is one of stdstring length64 newarray\n"
+"                                multipleinheritance all none\n"
 "    --show-reachable=yes             same as --show-leak-kinds=all\n"
 "    --show-reachable=no --show-possibly-lost=yes\n"
 "                                     same as --show-leak-kinds=definite,possible\n"
@@ -5508,7 +5510,8 @@ static void print_monitor_help ( void )
 "                [unlimited*|limited <max_loss_records_output>]\n"
 "            * = defaults\n"
 "       where kind is one of definite indirect possible reachable all none\n"
-"       where heur is one of stdstring newarray multipleinheritance all none*\n"
+"       where heur is one of stdstring length64 newarray\n"
+"                               multipleinheritance all none*\n"
 "        Examples: leak_check\n"
 "                  leak_check summary any\n"
 "                  leak_check full kinds indirect,possible\n"
index 7fd37d5e85feaaa31a2ea3a01d3fb038ba0d1ded..f599eaea40c49588fa39915b0e17dcb93ac83037 100644 (file)
@@ -1,5 +1,7 @@
 #include <stdio.h>
 #include <unistd.h>
+#include <stdint.h>
+#include <stdlib.h>
 #include <string>
 #include <sstream>
 #include "../memcheck.h"
@@ -7,6 +9,8 @@
 
 class MyClass
 { 
+   char m1;
+   int  m2;
 public:
    ~MyClass() 
    { fprintf(stderr, "destruct MyClass\n"); 
@@ -65,6 +69,23 @@ struct C : public A, public B
    } 
 };
 
+void* wrap64_malloc(int size)
+{
+  uint64_t *p = (uint64_t*)malloc(size + 8);
+  *p = size;
+  ++p;
+  return p;
+}
+
+void wrap64_free(void *p)
+{
+  uint64_t *p2 = (uint64_t*)p;
+  if (p2 == NULL)
+    return;
+  --p2;
+  free(p2);
+}
+
 std::string str;
 std::string str2;
 MyClass *ptr;
@@ -73,6 +94,7 @@ Be *ptrBCe;
 Ae *ptrACe;
 B *ptrBC;
 A *ptrAC;
+void* ptr64;
 
 char who_points_at_cmd[100];
 
@@ -81,6 +103,7 @@ void doit(void)
   str = "Valgrind"; // interior ptr.
   str2 = str;
   ptr = new MyClass[3]; // interior ptr.
+  ptr64 = wrap64_malloc(23);
   
   // prepare the who_points_at cmd we will run.
   // Do it here to avoid having ptr or its exterior ptr kept in a register.
@@ -112,9 +135,19 @@ int main() {
    (void) VALGRIND_MONITOR_COMMAND("leak_check summary heuristics multipleinheritance");
    fprintf(stderr, "leak_check summary any heuristics newarray\n");
    (void) VALGRIND_MONITOR_COMMAND("leak_check summary heuristics newarray");
+   fprintf(stderr, "leak_check summary heuristics length64\n");
+   (void) VALGRIND_MONITOR_COMMAND("leak_check summary heuristics length64");
    fprintf(stderr, "leak_check summary heuristics stdstring\n");
    (void) VALGRIND_MONITOR_COMMAND("leak_check summary heuristics stdstring");
 
+   // check all and none
+   fprintf(stderr, "leak_check summary heuristics multipleinheritance,newarray,stdstring,length64\n");
+   (void) VALGRIND_MONITOR_COMMAND("leak_check summary heuristics multipleinheritance,newarray,stdstring,length64");
+   fprintf(stderr, "leak_check summary heuristics all\n");
+   (void) VALGRIND_MONITOR_COMMAND("leak_check summary heuristics all");
+   fprintf(stderr, "leak_check summary heuristics none\n");
+   (void) VALGRIND_MONITOR_COMMAND("leak_check summary heuristics none");
+
    // Test the who_points_at when the block is pointed to with an interior ptr.
    (void) VALGRIND_MONITOR_COMMAND(who_points_at_cmd);
 
@@ -124,6 +157,7 @@ int main() {
    delete ptrACe;
    delete ptrBC;
    delete ptrAC;
+   wrap64_free(ptr64);
    fprintf(stderr, "Finished!\n");
    return 0;
 }
index deeb4c9216cf5241e82ea1f675e55356c120f450..8531c4ecc0af6f6782d3ae8b2b61716054dac606 100644 (file)
@@ -2,17 +2,18 @@
 valgrind output will go to log
 VALGRIND_DO_LEAK_CHECK
 4 bytes in 1 blocks are definitely lost in loss record ... of ...
-   by 0x........: doit() (leak_cpp_interior.cpp:89)
-   by 0x........: main (leak_cpp_interior.cpp:104)
+   by 0x........: doit() (leak_cpp_interior.cpp:112)
+   by 0x........: main (leak_cpp_interior.cpp:127)
 
 LEAK SUMMARY:
    definitely lost: 4 bytes in 1 blocks
    indirectly lost: 0 bytes in 0 blocks
      possibly lost: 0 bytes in 0 blocks
-   still reachable: 111 bytes in 7 blocks
+   still reachable: 163 bytes in 8 blocks
                       of which reachable via heuristic:
                         stdstring          : 56 bytes in 2 blocks
-                        newarray           : 7 bytes in 1 blocks
+                        length64           : 31 bytes in 1 blocks
+                        newarray           : 28 bytes in 1 blocks
                         multipleinheritance: 24 bytes in 2 blocks
         suppressed: 0 bytes in 0 blocks
 Reachable blocks (those to which a pointer was found) are not shown.
@@ -22,11 +23,12 @@ leak_check summary heuristics multipleinheritance
 LEAK SUMMARY:
    definitely lost: 4 (+0) bytes in 1 (+0) blocks
    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
-     possibly lost: 63 (+63) bytes in 3 (+3) blocks
-   still reachable: 48 (-63) bytes in 4 (-3) blocks
+     possibly lost: 115 (+115) bytes in 4 (+4) blocks
+   still reachable: 48 (-115) bytes in 4 (-4) blocks
                       of which reachable via heuristic:
                         stdstring          : 0 (-56) bytes in 0 (-2) blocks
-                        newarray           : 0 (-7) bytes in 0 (-1) blocks
+                        length64           : 0 (-31) bytes in 0 (-1) blocks
+                        newarray           : 0 (-28) bytes in 0 (-1) blocks
                         multipleinheritance: 24 (+0) bytes in 2 (+0) blocks
         suppressed: 0 (+0) bytes in 0 (+0) blocks
 To see details of leaked memory, give 'full' arg to leak_check
@@ -35,23 +37,77 @@ leak_check summary any heuristics newarray
 LEAK SUMMARY:
    definitely lost: 4 (+0) bytes in 1 (+0) blocks
    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
-     possibly lost: 80 (+17) bytes in 4 (+1) blocks
-   still reachable: 31 (-17) bytes in 3 (-1) blocks
+     possibly lost: 111 (-4) bytes in 5 (+1) blocks
+   still reachable: 52 (+4) bytes in 3 (-1) blocks
                       of which reachable via heuristic:
-                        newarray           : 7 (+7) bytes in 1 (+1) blocks
+                        newarray           : 28 (+28) bytes in 1 (+1) blocks
                         multipleinheritance: 0 (-24) bytes in 0 (-2) blocks
         suppressed: 0 (+0) bytes in 0 (+0) blocks
 To see details of leaked memory, give 'full' arg to leak_check
 
+leak_check summary heuristics length64
+LEAK SUMMARY:
+   definitely lost: 4 (+0) bytes in 1 (+0) blocks
+   indirectly lost: 0 (+0) bytes in 0 (+0) blocks
+     possibly lost: 108 (-3) bytes in 5 (+0) blocks
+   still reachable: 55 (+3) bytes in 3 (+0) blocks
+                      of which reachable via heuristic:
+                        length64           : 31 (+31) bytes in 1 (+1) blocks
+                        newarray           : 0 (-28) bytes in 0 (-1) blocks
+        suppressed: 0 (+0) bytes in 0 (+0) blocks
+To see details of leaked memory, give 'full' arg to leak_check
+
 leak_check summary heuristics stdstring
 LEAK SUMMARY:
    definitely lost: 4 (+0) bytes in 1 (+0) blocks
    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
-     possibly lost: 31 (-49) bytes in 3 (-1) blocks
-   still reachable: 80 (+49) bytes in 4 (+1) blocks
+     possibly lost: 83 (-25) bytes in 4 (-1) blocks
+   still reachable: 80 (+25) bytes in 4 (+1) blocks
                       of which reachable via heuristic:
                         stdstring          : 56 (+56) bytes in 2 (+2) blocks
-                        newarray           : 0 (-7) bytes in 0 (-1) blocks
+                        length64           : 0 (-31) bytes in 0 (-1) blocks
+        suppressed: 0 (+0) bytes in 0 (+0) blocks
+To see details of leaked memory, give 'full' arg to leak_check
+
+leak_check summary heuristics multipleinheritance,newarray,stdstring,length64
+LEAK SUMMARY:
+   definitely lost: 4 (+0) bytes in 1 (+0) blocks
+   indirectly lost: 0 (+0) bytes in 0 (+0) blocks
+     possibly lost: 0 (-83) bytes in 0 (-4) blocks
+   still reachable: 163 (+83) bytes in 8 (+4) blocks
+                      of which reachable via heuristic:
+                        stdstring          : 56 (+0) bytes in 2 (+0) blocks
+                        length64           : 31 (+31) bytes in 1 (+1) blocks
+                        newarray           : 28 (+28) bytes in 1 (+1) blocks
+                        multipleinheritance: 24 (+24) bytes in 2 (+2) blocks
+        suppressed: 0 (+0) bytes in 0 (+0) blocks
+To see details of leaked memory, give 'full' arg to leak_check
+
+leak_check summary heuristics all
+LEAK SUMMARY:
+   definitely lost: 4 (+0) bytes in 1 (+0) blocks
+   indirectly lost: 0 (+0) bytes in 0 (+0) blocks
+     possibly lost: 0 (+0) bytes in 0 (+0) blocks
+   still reachable: 163 (+0) bytes in 8 (+0) blocks
+                      of which reachable via heuristic:
+                        stdstring          : 56 (+0) bytes in 2 (+0) blocks
+                        length64           : 31 (+0) bytes in 1 (+0) blocks
+                        newarray           : 28 (+0) bytes in 1 (+0) blocks
+                        multipleinheritance: 24 (+0) bytes in 2 (+0) blocks
+        suppressed: 0 (+0) bytes in 0 (+0) blocks
+To see details of leaked memory, give 'full' arg to leak_check
+
+leak_check summary heuristics none
+LEAK SUMMARY:
+   definitely lost: 4 (+0) bytes in 1 (+0) blocks
+   indirectly lost: 0 (+0) bytes in 0 (+0) blocks
+     possibly lost: 139 (+139) bytes in 6 (+6) blocks
+   still reachable: 24 (-139) bytes in 2 (-6) blocks
+                      of which reachable via heuristic:
+                        stdstring          : 0 (-56) bytes in 0 (-2) blocks
+                        length64           : 0 (-31) bytes in 0 (-1) blocks
+                        newarray           : 0 (-28) bytes in 0 (-1) blocks
+                        multipleinheritance: 0 (-24) bytes in 0 (-2) blocks
         suppressed: 0 (+0) bytes in 0 (+0) blocks
 To see details of leaked memory, give 'full' arg to leak_check
 
@@ -78,7 +134,7 @@ Finished!
 
 HEAP SUMMARY:
     in use at exit: 0 bytes in 0 blocks
-  total heap usage: 8 allocs, 8 frees, 115 bytes allocated
+  total heap usage: 9 allocs, 9 frees, 167 bytes allocated
 
 All heap blocks were freed -- no leaks are possible
 
index 18b54787b1b226d90e8063d56043eb12b7cba279..8a025a9650275eceda7c07a351d8f9f21850f6b5 100644 (file)
@@ -2,17 +2,18 @@
 valgrind output will go to log
 VALGRIND_DO_LEAK_CHECK
 8 bytes in 1 blocks are definitely lost in loss record ... of ...
-   by 0x........: doit() (leak_cpp_interior.cpp:89)
-   by 0x........: main (leak_cpp_interior.cpp:104)
+   by 0x........: doit() (leak_cpp_interior.cpp:112)
+   by 0x........: main (leak_cpp_interior.cpp:127)
 
 LEAK SUMMARY:
    definitely lost: 8 bytes in 1 blocks
    indirectly lost: 0 bytes in 0 blocks
      possibly lost: 0 bytes in 0 blocks
-   still reachable: 187 bytes in 7 blocks
+   still reachable: 239 bytes in 8 blocks
                       of which reachable via heuristic:
                         stdstring          : 80 bytes in 2 blocks
-                        newarray           : 11 bytes in 1 blocks
+                        length64           : 31 bytes in 1 blocks
+                        newarray           : 32 bytes in 1 blocks
                         multipleinheritance: 48 bytes in 2 blocks
         suppressed: 0 bytes in 0 blocks
 Reachable blocks (those to which a pointer was found) are not shown.
@@ -22,11 +23,12 @@ leak_check summary heuristics multipleinheritance
 LEAK SUMMARY:
    definitely lost: 8 (+0) bytes in 1 (+0) blocks
    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
-     possibly lost: 91 (+91) bytes in 3 (+3) blocks
-   still reachable: 96 (-91) bytes in 4 (-3) blocks
+     possibly lost: 143 (+143) bytes in 4 (+4) blocks
+   still reachable: 96 (-143) bytes in 4 (-4) blocks
                       of which reachable via heuristic:
                         stdstring          : 0 (-80) bytes in 0 (-2) blocks
-                        newarray           : 0 (-11) bytes in 0 (-1) blocks
+                        length64           : 0 (-31) bytes in 0 (-1) blocks
+                        newarray           : 0 (-32) bytes in 0 (-1) blocks
                         multipleinheritance: 48 (+0) bytes in 2 (+0) blocks
         suppressed: 0 (+0) bytes in 0 (+0) blocks
 To see details of leaked memory, give 'full' arg to leak_check
@@ -35,23 +37,77 @@ leak_check summary any heuristics newarray
 LEAK SUMMARY:
    definitely lost: 8 (+0) bytes in 1 (+0) blocks
    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
-     possibly lost: 128 (+37) bytes in 4 (+1) blocks
-   still reachable: 59 (-37) bytes in 3 (-1) blocks
+     possibly lost: 128 (-15) bytes in 4 (+0) blocks
+   still reachable: 111 (+15) bytes in 4 (+0) blocks
                       of which reachable via heuristic:
-                        newarray           : 11 (+11) bytes in 1 (+1) blocks
+                        newarray           : 63 (+63) bytes in 2 (+2) blocks
                         multipleinheritance: 0 (-48) bytes in 0 (-2) blocks
         suppressed: 0 (+0) bytes in 0 (+0) blocks
 To see details of leaked memory, give 'full' arg to leak_check
 
+leak_check summary heuristics length64
+LEAK SUMMARY:
+   definitely lost: 8 (+0) bytes in 1 (+0) blocks
+   indirectly lost: 0 (+0) bytes in 0 (+0) blocks
+     possibly lost: 160 (+32) bytes in 5 (+1) blocks
+   still reachable: 79 (-32) bytes in 3 (-1) blocks
+                      of which reachable via heuristic:
+                        length64           : 31 (+31) bytes in 1 (+1) blocks
+                        newarray           : 0 (-63) bytes in 0 (-2) blocks
+        suppressed: 0 (+0) bytes in 0 (+0) blocks
+To see details of leaked memory, give 'full' arg to leak_check
+
 leak_check summary heuristics stdstring
 LEAK SUMMARY:
    definitely lost: 8 (+0) bytes in 1 (+0) blocks
    indirectly lost: 0 (+0) bytes in 0 (+0) blocks
-     possibly lost: 59 (-69) bytes in 3 (-1) blocks
-   still reachable: 128 (+69) bytes in 4 (+1) blocks
+     possibly lost: 111 (-49) bytes in 4 (-1) blocks
+   still reachable: 128 (+49) bytes in 4 (+1) blocks
                       of which reachable via heuristic:
                         stdstring          : 80 (+80) bytes in 2 (+2) blocks
-                        newarray           : 0 (-11) bytes in 0 (-1) blocks
+                        length64           : 0 (-31) bytes in 0 (-1) blocks
+        suppressed: 0 (+0) bytes in 0 (+0) blocks
+To see details of leaked memory, give 'full' arg to leak_check
+
+leak_check summary heuristics multipleinheritance,newarray,stdstring,length64
+LEAK SUMMARY:
+   definitely lost: 8 (+0) bytes in 1 (+0) blocks
+   indirectly lost: 0 (+0) bytes in 0 (+0) blocks
+     possibly lost: 0 (-111) bytes in 0 (-4) blocks
+   still reachable: 239 (+111) bytes in 8 (+4) blocks
+                      of which reachable via heuristic:
+                        stdstring          : 80 (+0) bytes in 2 (+0) blocks
+                        length64           : 31 (+31) bytes in 1 (+1) blocks
+                        newarray           : 32 (+32) bytes in 1 (+1) blocks
+                        multipleinheritance: 48 (+48) bytes in 2 (+2) blocks
+        suppressed: 0 (+0) bytes in 0 (+0) blocks
+To see details of leaked memory, give 'full' arg to leak_check
+
+leak_check summary heuristics all
+LEAK SUMMARY:
+   definitely lost: 8 (+0) bytes in 1 (+0) blocks
+   indirectly lost: 0 (+0) bytes in 0 (+0) blocks
+     possibly lost: 0 (+0) bytes in 0 (+0) blocks
+   still reachable: 239 (+0) bytes in 8 (+0) blocks
+                      of which reachable via heuristic:
+                        stdstring          : 80 (+0) bytes in 2 (+0) blocks
+                        length64           : 31 (+0) bytes in 1 (+0) blocks
+                        newarray           : 32 (+0) bytes in 1 (+0) blocks
+                        multipleinheritance: 48 (+0) bytes in 2 (+0) blocks
+        suppressed: 0 (+0) bytes in 0 (+0) blocks
+To see details of leaked memory, give 'full' arg to leak_check
+
+leak_check summary heuristics none
+LEAK SUMMARY:
+   definitely lost: 8 (+0) bytes in 1 (+0) blocks
+   indirectly lost: 0 (+0) bytes in 0 (+0) blocks
+     possibly lost: 191 (+191) bytes in 6 (+6) blocks
+   still reachable: 48 (-191) bytes in 2 (-6) blocks
+                      of which reachable via heuristic:
+                        stdstring          : 0 (-80) bytes in 0 (-2) blocks
+                        length64           : 0 (-31) bytes in 0 (-1) blocks
+                        newarray           : 0 (-32) bytes in 0 (-1) blocks
+                        multipleinheritance: 0 (-48) bytes in 0 (-2) blocks
         suppressed: 0 (+0) bytes in 0 (+0) blocks
 To see details of leaked memory, give 'full' arg to leak_check
 
@@ -78,7 +134,7 @@ Finished!
 
 HEAP SUMMARY:
     in use at exit: 0 bytes in 0 blocks
-  total heap usage: 8 allocs, 8 frees, 195 bytes allocated
+  total heap usage: 9 allocs, 9 frees, 247 bytes allocated
 
 All heap blocks were freed -- no leaks are possible
 
index 44eb45c39f5414493bc1257f404ed195c357e455..4ecc219023547616200d9cadd70399d4291f8b3b 100644 (file)
@@ -1,2 +1,2 @@
 prog: leak_cpp_interior
-vgopts: --leak-check=summary --leak-check-heuristics=multipleinheritance,stdstring,newarray 
+vgopts: --leak-check=summary --leak-check-heuristics=multipleinheritance,stdstring,newarray,length64