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
This commit is contained in:
Philippe Waroquiers 2015-08-29 10:45:26 +00:00
parent 2c1bd53275
commit 8f0961e770
24 changed files with 92 additions and 11 deletions

6
NEWS
View File

@ -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

View 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

View 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
);

View 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:

View 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

View 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

View File

@ -1,2 +1,2 @@
prog: custom_alloc
vgopts: -q
vgopts: -q --keep-stacktraces=alloc-then-free

View 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)

View 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 ---------

View 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) ---------

View 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)

View 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) ------

View 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.

View File

@ -1,2 +1,2 @@
vgopts: -q
vgopts: -q --keep-stacktraces=alloc-then-free
prog: fprw

View 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)

View 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)

View 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)

View 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:

View File

@ -1,3 +1,4 @@
prog: partial_load
vgopts: --keep-stacktraces=alloc-then-free
stderr_filter: filter_allocs
stderr_filter_args: partial_load.c

View 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

View 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)

View File

@ -1,2 +1,2 @@
prog: test-plo
vgopts: -q
vgopts: -q --keep-stacktraces=alloc-then-free

View 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

View 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