]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Change default value for --keep-stacktraces has been changed to alloc-and-free
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 29 Aug 2015 10:45:26 +0000 (10:45 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 29 Aug 2015 10:45:26 +0000 (10:45 +0000)
Default value changed following discussion on valdev.

Giving more information for errors with freed blocks can help
when investigating difficult problems (e.g. double free, programs
using 'cleanup list' collecting different types of memory, ...)

Regression tested on various setup (x86, ppc64, s390x, amd64, debian or fedora)

Tests that have only one exp files have been updated to use the output
of the new default value in their .exp file.

Tests having more than one exp file have been changed so as to
specify explicitely the previous clo default value (i.e. adding
 --keep-stacktraces=alloc-then-free in the vgtest file).

Possibly, some tests might fail on non tested platforms
(e.g. mips, macos, solaris, tilegx).
Fixes should be straightforward, using one of the above fix techniques.

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

24 files changed:
NEWS
memcheck/docs/mc-manual.xml
memcheck/mc_main.c
memcheck/tests/big_blocks_freed_list.stderr.exp
memcheck/tests/cond_ld.vgtest
memcheck/tests/cond_st.vgtest
memcheck/tests/custom_alloc.vgtest
memcheck/tests/doublefree.stderr.exp
memcheck/tests/err_disable1.stderr.exp
memcheck/tests/err_disable2.stderr.exp
memcheck/tests/err_disable3.stderr.exp
memcheck/tests/err_disable4.stderr.exp
memcheck/tests/err_disable_arange1.stderr.exp
memcheck/tests/fprw.vgtest
memcheck/tests/malloc1.stderr.exp
memcheck/tests/malloc2.stderr.exp
memcheck/tests/memalign_test.stderr.exp
memcheck/tests/noisy_child.stderr.exp
memcheck/tests/partial_load_dflt.vgtest
memcheck/tests/partial_load_ok.vgtest
memcheck/tests/suppfree.stderr.exp
memcheck/tests/test-plo-no.vgtest
memcheck/tests/test-plo-yes.vgtest
memcheck/tests/xml1.vgtest

diff --git a/NEWS b/NEWS
index a861700915c26dfadcc892b5a6818aaf9cc08d8e..ae0ad720a72553ba53e04b8e054c322be038f636 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -33,6 +33,12 @@ X86/MacOSX 10.10 and 10.11 and AMD64/MacOSX 10.10 and 10.11.
 
 * Memcheck:
 
+  - Default value for --keep-stacktraces has been changed to alloc-and-free.
+    This has a small cost in memory (one word per malloc-ed block) but
+    allows memcheck to e.g. give the 3 stacktraces of a dangling reference:
+    Where the block was allocated, where it was freed, and where it is
+    acccessed after free.
+
   - A new monitor command 'xb <addr> <len>' shows the validity bits of
     <len> bytes at <addr>.  The monitor command 'xb' is easier to use
     than get_vbits when you need to associate byte data value with
index 4b70e64a1b5dbd0c0855595632b575f9178cadfe..1aa7eff3ec7bcdab6aa19a11f249712f85d5f5bb 100644 (file)
@@ -990,7 +990,7 @@ is <option>--errors-for-leak-kinds=definite,possible</option>
 
   <varlistentry id="opt.keep-stacktraces" xreflabel="--keep-stacktraces">
     <term>
-      <option><![CDATA[--keep-stacktraces=alloc|free|alloc-and-free|alloc-then-free|none [default: alloc-then-free] ]]></option>
+      <option><![CDATA[--keep-stacktraces=alloc|free|alloc-and-free|alloc-then-free|none [default: alloc-and-free] ]]></option>
     </term>
     <listitem>
       <para>Controls which stack trace(s) to keep for malloc'd and/or
index 674a50d713cec7f989f4e7bf805402fc8760d662..e3ed7139a52a19450465917ee60918fdd0687874 100644 (file)
@@ -5708,7 +5708,7 @@ UInt          MC_(clo_leak_check_heuristics)  = 0;
 Bool          MC_(clo_workaround_gcc296_bugs) = False;
 Int           MC_(clo_malloc_fill)            = -1;
 Int           MC_(clo_free_fill)              = -1;
-KeepStacktraces MC_(clo_keep_stacktraces)     = KS_alloc_then_free;
+KeepStacktraces MC_(clo_keep_stacktraces)     = KS_alloc_and_free;
 Int           MC_(clo_mc_level)               = 2;
 Bool          MC_(clo_show_mismatched_frees)  = True;
 Bool          MC_(clo_expensive_definedness_check) = False;
@@ -5907,7 +5907,7 @@ static void mc_print_usage(void)
 "    --malloc-fill=<hexnumber>        fill malloc'd areas with given value\n"
 "    --free-fill=<hexnumber>          fill free'd areas with given value\n"
 "    --keep-stacktraces=alloc|free|alloc-and-free|alloc-then-free|none\n"
-"        stack trace(s) to keep for malloc'd/free'd areas       [alloc-then-free]\n"
+"        stack trace(s) to keep for malloc'd/free'd areas       [alloc-and-free]\n"
 "    --show-mismatched-frees=no|yes   show frees that don't match the allocator? [yes]\n"
 , plo_default
    );
index 3c4c7286fb0790029153b9496034ae4f0d0d225e..d0fd803a6022cd9a97f3a79b300846d0fbdf6013 100644 (file)
@@ -4,12 +4,18 @@ Invalid read of size 1
  Address 0x........ is 1,000 bytes inside a block of size 1,000,015 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (big_blocks_freed_list.c:21)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (big_blocks_freed_list.c:19)
 
 Invalid read of size 1
    at 0x........: main (big_blocks_freed_list.c:23)
  Address 0x........ is 1,000 bytes inside a block of size 900,000 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (big_blocks_freed_list.c:20)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (big_blocks_freed_list.c:18)
 
 Invalid read of size 1
    at 0x........: main (big_blocks_freed_list.c:33)
@@ -20,24 +26,36 @@ Invalid read of size 1
  Address 0x........ is 2,000 bytes inside a block of size 900,000 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (big_blocks_freed_list.c:20)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (big_blocks_freed_list.c:18)
 
 Invalid read of size 1
    at 0x........: main (big_blocks_freed_list.c:41)
  Address 0x........ is 10 bytes inside a block of size 10,000 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (big_blocks_freed_list.c:28)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (big_blocks_freed_list.c:27)
 
 Invalid read of size 1
    at 0x........: main (big_blocks_freed_list.c:46)
  Address 0x........ is 10 bytes inside a block of size 1,000,015 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (big_blocks_freed_list.c:40)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (big_blocks_freed_list.c:39)
 
 Invalid read of size 1
    at 0x........: main (big_blocks_freed_list.c:55)
  Address 0x........ is 10 bytes inside a block of size 10,000 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (big_blocks_freed_list.c:28)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (big_blocks_freed_list.c:27)
 
 
 HEAP SUMMARY:
index acc0bfe04f3d252a61b8a35e5178a9eedc70285c..5c83e2689f86d988609c18a21d772da7b6c7df19 100644 (file)
@@ -1,4 +1,4 @@
 prog: cond_ld_st
 args: loads
-vgopts: -q
+vgopts: -q --keep-stacktraces=alloc-then-free
 stderr_filter_args: cond_ld_st
index 2ccf00c4a7ba75719aaf06d69a9082f7fa3b8563..fbb8181a78ee588490de31035fffa03cd42ebfa3 100644 (file)
@@ -1,4 +1,4 @@
 prog: cond_ld_st
 args: stores
-vgopts: -q
+vgopts: -q --keep-stacktraces=alloc-then-free
 stderr_filter_args: cond_ld_st
index 9c7fa41061fc9db9fd0a3249cf2eb61cd39ad12e..04727563224dd3c952000a7fdf9c1e9fe8f6b599 100644 (file)
@@ -1,2 +1,2 @@
 prog: custom_alloc
-vgopts: -q
+vgopts: -q --keep-stacktraces=alloc-then-free
index 9ed5375c72623819106b5d2a3b7abe5903efc1ed..7560e3a77ec9d01b217b601497d0d4af84bfc7d1 100644 (file)
@@ -4,4 +4,7 @@ Invalid free() / delete / delete[] / realloc()
  Address 0x........ is 0 bytes inside a block of size 177 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (doublefree.c:10)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (doublefree.c:8)
 
index 8762bf1d4c6224a2001f2674a7b4a6cf72d8b515..02bf2599d8be2e48e9d57f98f54bf4210fe9cb83 100644 (file)
@@ -10,6 +10,9 @@ Invalid read of size 1
  Address 0x........ is 5 bytes inside a block of size 10 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (err_disable1.c:27)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (err_disable1.c:26)
 
 
 --------- disabled (expect 0) ---------
@@ -23,6 +26,9 @@ Invalid read of size 1
  Address 0x........ is 5 bytes inside a block of size 10 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (err_disable1.c:27)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (err_disable1.c:26)
 
 
 --------- MULTI-LEVEL TEST (expect 2) ---------
@@ -33,6 +39,9 @@ Invalid read of size 1
  Address 0x........ is 5 bytes inside a block of size 10 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (err_disable1.c:27)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (err_disable1.c:26)
 
 Invalid read of size 1
    at 0x........: err (err_disable1.c:21)
@@ -40,6 +49,9 @@ Invalid read of size 1
  Address 0x........ is 5 bytes inside a block of size 10 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (err_disable1.c:27)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (err_disable1.c:26)
 
 
 --------- MULTI-LEVEL TEST end ---------
index 82cd04f44930eb28e98c813f632a67875386dbb3..7146da7a0a1d73308b5b4225408b19909ed264cf 100644 (file)
@@ -7,6 +7,9 @@ Invalid read of size 1
  Address 0x........ is 5 bytes inside a block of size 10 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (err_disable2.c:28)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (err_disable2.c:27)
 
 
 --------- disabled (expect 0) ---------
index 0f1f8b7707d2084d420b295968a793ce4aadedcf..2b6d74d6ed05a77f1fa6be39e68b4346c7f5957a 100644 (file)
@@ -15,6 +15,9 @@ Invalid read of size 1
  Address 0x........ is 5 bytes inside a block of size 10 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (err_disable3.c:42)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (err_disable3.c:41)
 
 
 --------- c: end ---------
@@ -32,4 +35,7 @@ Invalid read of size 1
  Address 0x........ is 5 bytes inside a block of size 10 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (err_disable3.c:42)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (err_disable3.c:41)
 
index cfacfd783963bd298f46913a7bc2ae7a6f86e8f1..acc01ad823b4ed1edc846e07b496abf95fdceb0b 100644 (file)
@@ -1506,6 +1506,9 @@ Invalid read of size 1
  Address 0x........ is 5 bytes inside a block of size 10 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (err_disable4.c:81)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (err_disable4.c:80)
 
 
 -------- Got 498 errors (expected 498 ==> PASS) ------
index cb6a2db620febb47bc66944362222abe1462aa98..35257d16caced80de4a1bbbcfb60a55c97c27990 100644 (file)
@@ -6,6 +6,9 @@ Invalid write of size 4
  Address 0x........ is 492 bytes inside a block of size 4,000 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (err_disable_arange1.c:15)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (err_disable_arange1.c:14)
 
 
 Disabling address error reporting for the range.
@@ -24,6 +27,9 @@ Invalid write of size 4
  Address 0x........ is 3,156 bytes inside a block of size 4,000 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (err_disable_arange1.c:15)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (err_disable_arange1.c:14)
 
 
 Exiting.  Expect warnings of 2 remaining ranges.
index 6dfbf0cb403ebcb36f15085da1b8fb9dd83b6abf..4179391b1c7993636a5e7e61fd6643b95bbefabc 100644 (file)
@@ -1,2 +1,2 @@
-vgopts: -q
+vgopts: -q --keep-stacktraces=alloc-then-free
 prog:   fprw
index b440a83806de4528e4daaf9cf73cf507f384477b..bbf8041226ef7854cc9e170a5a238aa6002da93f 100644 (file)
@@ -5,6 +5,10 @@ Invalid write of size 1
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: really (malloc1.c:19)
    by 0x........: main (malloc1.c:9)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: really (malloc1.c:16)
+   by 0x........: main (malloc1.c:9)
 
 Invalid write of size 1
    at 0x........: really (malloc1.c:23)
index f1a075b654bb48529f55b2038313d880b869ac9a..36fb8482324722c43275f2c5d3b641ccf0f29815 100644 (file)
@@ -3,6 +3,9 @@ Invalid write of size 1
  Address 0x........ is 0 bytes inside a block of size 772 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (malloc2.c:49)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (malloc2.c:41)
 
 Invalid free() / delete / delete[] / realloc()
    at 0x........: free (vg_replace_malloc.c:...)
@@ -10,4 +13,7 @@ Invalid free() / delete / delete[] / realloc()
  Address 0x........ is 0 bytes inside a block of size 772 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (malloc2.c:49)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (malloc2.c:41)
 
index aa8d5883365bb4c6bedc79a34f0e5221cab980b4..e9dc1afe50ded90d5cc7414ac27beb0c78383a5b 100644 (file)
@@ -4,4 +4,8 @@ Invalid free() / delete / delete[] / realloc()
  Address 0x........ is 0 bytes inside a block of size 111,110 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (memalign_test.c:23)
+ Block was alloc'd at
+   at 0x........: memalign (vg_replace_malloc.c:...)
+   by 0x........: valloc (vg_replace_malloc.c:...)
+   by 0x........: main (memalign_test.c:16)
 
index 2f583438bb776fc224dccf40794814b0e2f09858..675fc643d8968dfdba216cafd9cbfc2a0adad05f 100644 (file)
@@ -4,6 +4,9 @@ Invalid write of size 1
  Address 0x........ is 5 bytes inside a block of size 10 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (noisy_child.c:24)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (noisy_child.c:23)
 
 Invalid write of size 1
    at 0x........: do_parent_badness (noisy_child.c:16)
@@ -11,6 +14,9 @@ Invalid write of size 1
  Address 0x........ is 0 bytes after a block of size 10 free'd
    at 0x........: free (vg_replace_malloc.c:...)
    by 0x........: main (noisy_child.c:24)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (noisy_child.c:23)
 
 
 HEAP SUMMARY:
index b1c6b27c4782adf861122e5dd6bb094886ca5672..a95bb6289d4290765eff9aed37add0dc79659b19 100644 (file)
@@ -1,3 +1,4 @@
 prog: partial_load
+vgopts: --keep-stacktraces=alloc-then-free
 stderr_filter: filter_allocs
 stderr_filter_args: partial_load.c
index d4003a77d3defc16ed091abf2514ca50c128bd63..0c9caa1089ce1627733c43a35493af78c1a99804 100644 (file)
@@ -1,4 +1,4 @@
 prog: partial_load
-vgopts: --partial-loads-ok=yes
+vgopts: --partial-loads-ok=yes --keep-stacktraces=alloc-then-free
 stderr_filter: filter_allocs
 stderr_filter_args: partial_load.c
index 62f5cccc7837d5e2954854abf30dd6e6c57676ce..0340e61c1db153eb0e38e4ae488343b143a97fd6 100644 (file)
@@ -12,4 +12,7 @@ Invalid free() / delete / delete[] / realloc()
    by 0x........: bbb (suppfree.c:17)
    by 0x........: aaa (suppfree.c:22)
    by 0x........: main (suppfree.c:36)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (suppfree.c:32)
 
index 247a134894d64b453ca513b57ce0cc99c7b92b26..14d4be32e46eea06cad9e7c0c427f2fa4f8d6c08 100644 (file)
@@ -1,2 +1,2 @@
 prog: test-plo
-vgopts: -q
+vgopts: -q --keep-stacktraces=alloc-then-free
index ace614ceccf70cc9f29c9678bfd9c9a4f5090d77..b37aeb5d3d9b7fa4d429c976f996c46ccc33144c 100644 (file)
@@ -1,3 +1,3 @@
 prereq: ! ../../tests/arch_test ppc32 && ! ../../tests/arch_test ppc64 && ! ../../tests/arch_test s390x && ! ../../tests/mips_features mips-be
 prog: test-plo
-vgopts: -q --partial-loads-ok=yes
+vgopts: -q --partial-loads-ok=yes  --keep-stacktraces=alloc-then-free
index 4d83a9faac81a8f44a96d55d87a33260e909a977..6585b18f42f76ae20d96947ac291509e8fea948d 100644 (file)
@@ -1,3 +1,3 @@
 prog: xml1
-vgopts: --xml=yes --xml-fd=2 --log-file=/dev/null
+vgopts: --xml=yes --xml-fd=2 --log-file=/dev/null --keep-stacktraces=alloc-then-free
 stderr_filter: filter_xml