From: Philippe Waroquiers Date: Sat, 29 Aug 2015 10:45:26 +0000 (+0000) Subject: Change default value for --keep-stacktraces has been changed to alloc-and-free X-Git-Tag: svn/VALGRIND_3_11_0~60 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f0961e770bf74e568d69a75822c4de06ea65d60;p=thirdparty%2Fvalgrind.git Change default value for --keep-stacktraces has been changed to alloc-and-free 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 --- diff --git a/NEWS b/NEWS index a861700915..ae0ad720a7 100644 --- 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 ' shows the validity bits of bytes at . The monitor command 'xb' is easier to use than get_vbits when you need to associate byte data value with diff --git a/memcheck/docs/mc-manual.xml b/memcheck/docs/mc-manual.xml index 4b70e64a1b..1aa7eff3ec 100644 --- a/memcheck/docs/mc-manual.xml +++ b/memcheck/docs/mc-manual.xml @@ -990,7 +990,7 @@ is - + Controls which stack trace(s) to keep for malloc'd and/or diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c index 674a50d713..e3ed7139a5 100644 --- a/memcheck/mc_main.c +++ b/memcheck/mc_main.c @@ -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= fill malloc'd areas with given value\n" " --free-fill= 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 ); diff --git a/memcheck/tests/big_blocks_freed_list.stderr.exp b/memcheck/tests/big_blocks_freed_list.stderr.exp index 3c4c7286fb..d0fd803a60 100644 --- a/memcheck/tests/big_blocks_freed_list.stderr.exp +++ b/memcheck/tests/big_blocks_freed_list.stderr.exp @@ -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: diff --git a/memcheck/tests/cond_ld.vgtest b/memcheck/tests/cond_ld.vgtest index acc0bfe04f..5c83e2689f 100644 --- a/memcheck/tests/cond_ld.vgtest +++ b/memcheck/tests/cond_ld.vgtest @@ -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 diff --git a/memcheck/tests/cond_st.vgtest b/memcheck/tests/cond_st.vgtest index 2ccf00c4a7..fbb8181a78 100644 --- a/memcheck/tests/cond_st.vgtest +++ b/memcheck/tests/cond_st.vgtest @@ -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 diff --git a/memcheck/tests/custom_alloc.vgtest b/memcheck/tests/custom_alloc.vgtest index 9c7fa41061..0472756322 100644 --- a/memcheck/tests/custom_alloc.vgtest +++ b/memcheck/tests/custom_alloc.vgtest @@ -1,2 +1,2 @@ prog: custom_alloc -vgopts: -q +vgopts: -q --keep-stacktraces=alloc-then-free diff --git a/memcheck/tests/doublefree.stderr.exp b/memcheck/tests/doublefree.stderr.exp index 9ed5375c72..7560e3a77e 100644 --- a/memcheck/tests/doublefree.stderr.exp +++ b/memcheck/tests/doublefree.stderr.exp @@ -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) diff --git a/memcheck/tests/err_disable1.stderr.exp b/memcheck/tests/err_disable1.stderr.exp index 8762bf1d4c..02bf2599d8 100644 --- a/memcheck/tests/err_disable1.stderr.exp +++ b/memcheck/tests/err_disable1.stderr.exp @@ -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 --------- diff --git a/memcheck/tests/err_disable2.stderr.exp b/memcheck/tests/err_disable2.stderr.exp index 82cd04f449..7146da7a0a 100644 --- a/memcheck/tests/err_disable2.stderr.exp +++ b/memcheck/tests/err_disable2.stderr.exp @@ -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) --------- diff --git a/memcheck/tests/err_disable3.stderr.exp b/memcheck/tests/err_disable3.stderr.exp index 0f1f8b7707..2b6d74d6ed 100644 --- a/memcheck/tests/err_disable3.stderr.exp +++ b/memcheck/tests/err_disable3.stderr.exp @@ -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) diff --git a/memcheck/tests/err_disable4.stderr.exp b/memcheck/tests/err_disable4.stderr.exp index cfacfd7839..acc01ad823 100644 --- a/memcheck/tests/err_disable4.stderr.exp +++ b/memcheck/tests/err_disable4.stderr.exp @@ -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) ------ diff --git a/memcheck/tests/err_disable_arange1.stderr.exp b/memcheck/tests/err_disable_arange1.stderr.exp index cb6a2db620..35257d16ca 100644 --- a/memcheck/tests/err_disable_arange1.stderr.exp +++ b/memcheck/tests/err_disable_arange1.stderr.exp @@ -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. diff --git a/memcheck/tests/fprw.vgtest b/memcheck/tests/fprw.vgtest index 6dfbf0cb40..4179391b1c 100644 --- a/memcheck/tests/fprw.vgtest +++ b/memcheck/tests/fprw.vgtest @@ -1,2 +1,2 @@ -vgopts: -q +vgopts: -q --keep-stacktraces=alloc-then-free prog: fprw diff --git a/memcheck/tests/malloc1.stderr.exp b/memcheck/tests/malloc1.stderr.exp index b440a83806..bbf8041226 100644 --- a/memcheck/tests/malloc1.stderr.exp +++ b/memcheck/tests/malloc1.stderr.exp @@ -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) diff --git a/memcheck/tests/malloc2.stderr.exp b/memcheck/tests/malloc2.stderr.exp index f1a075b654..36fb848232 100644 --- a/memcheck/tests/malloc2.stderr.exp +++ b/memcheck/tests/malloc2.stderr.exp @@ -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) diff --git a/memcheck/tests/memalign_test.stderr.exp b/memcheck/tests/memalign_test.stderr.exp index aa8d588336..e9dc1afe50 100644 --- a/memcheck/tests/memalign_test.stderr.exp +++ b/memcheck/tests/memalign_test.stderr.exp @@ -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) diff --git a/memcheck/tests/noisy_child.stderr.exp b/memcheck/tests/noisy_child.stderr.exp index 2f583438bb..675fc643d8 100644 --- a/memcheck/tests/noisy_child.stderr.exp +++ b/memcheck/tests/noisy_child.stderr.exp @@ -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: diff --git a/memcheck/tests/partial_load_dflt.vgtest b/memcheck/tests/partial_load_dflt.vgtest index b1c6b27c47..a95bb6289d 100644 --- a/memcheck/tests/partial_load_dflt.vgtest +++ b/memcheck/tests/partial_load_dflt.vgtest @@ -1,3 +1,4 @@ prog: partial_load +vgopts: --keep-stacktraces=alloc-then-free stderr_filter: filter_allocs stderr_filter_args: partial_load.c diff --git a/memcheck/tests/partial_load_ok.vgtest b/memcheck/tests/partial_load_ok.vgtest index d4003a77d3..0c9caa1089 100644 --- a/memcheck/tests/partial_load_ok.vgtest +++ b/memcheck/tests/partial_load_ok.vgtest @@ -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 diff --git a/memcheck/tests/suppfree.stderr.exp b/memcheck/tests/suppfree.stderr.exp index 62f5cccc78..0340e61c1d 100644 --- a/memcheck/tests/suppfree.stderr.exp +++ b/memcheck/tests/suppfree.stderr.exp @@ -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) diff --git a/memcheck/tests/test-plo-no.vgtest b/memcheck/tests/test-plo-no.vgtest index 247a134894..14d4be32e4 100644 --- a/memcheck/tests/test-plo-no.vgtest +++ b/memcheck/tests/test-plo-no.vgtest @@ -1,2 +1,2 @@ prog: test-plo -vgopts: -q +vgopts: -q --keep-stacktraces=alloc-then-free diff --git a/memcheck/tests/test-plo-yes.vgtest b/memcheck/tests/test-plo-yes.vgtest index ace614cecc..b37aeb5d3d 100644 --- a/memcheck/tests/test-plo-yes.vgtest +++ b/memcheck/tests/test-plo-yes.vgtest @@ -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 diff --git a/memcheck/tests/xml1.vgtest b/memcheck/tests/xml1.vgtest index 4d83a9faac..6585b18f42 100644 --- a/memcheck/tests/xml1.vgtest +++ b/memcheck/tests/xml1.vgtest @@ -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