Fix a bug reported by Bruce Lowekamp involving the interaction of

--gen-suppressions with leak checking.  Added a regtest for it.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6514
This commit is contained in:
Nicholas Nethercote 2007-01-12 23:59:50 +00:00
parent 20ce1d0a81
commit 824abc79ce
5 changed files with 32 additions and 6 deletions

View File

@ -474,6 +474,8 @@ void do_actions_on_error(Error* err, Bool allow_db_attach)
just for pretty printing purposes. */
static Bool is_first_shown_context = True;
static Int n_errs_shown = 0;
/* Top-level entry point to the error management subsystem.
All detected errors are notified here; this routine decides if/when the
user should see the error. */
@ -487,7 +489,6 @@ void VG_(maybe_record_error) ( ThreadId tid,
VgRes exe_res = Vg_MedRes;
static Bool stopping_message = False;
static Bool slowdown_message = False;
static Int n_errs_shown = 0;
/* After M_COLLECT_NO_ERRORS_AFTER_SHOWN different errors have
been found, or M_COLLECT_NO_ERRORS_AFTER_FOUND total errors
@ -649,7 +650,8 @@ Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind, Addr a, Char* s,
void* extra, ExeContext* where, Bool print_error,
Bool allow_db_attach, Bool count_error )
{
Error err;
Error err;
Supp *su;
/* Build ourselves the error */
construct_error ( &err, tid, ekind, a, s, extra, where );
@ -663,7 +665,8 @@ Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind, Addr a, Char* s,
not copying 'extra'. */
(void)VG_TDICT_CALL(tool_update_extra, &err);
if (NULL == is_suppressible_error(&err)) {
su = is_suppressible_error(&err);
if (NULL == su) {
if (count_error)
n_errs_found++;
@ -672,13 +675,14 @@ Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind, Addr a, Char* s,
VG_(message)(Vg_UserMsg, "");
pp_Error(&err);
is_first_shown_context = False;
n_errs_shown++;
do_actions_on_error(&err, allow_db_attach);
}
do_actions_on_error(&err, allow_db_attach);
return False;
} else {
n_errs_suppressed++;
su->count++;
return True;
}
}

View File

@ -81,6 +81,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
mmaptest.stderr.exp mmaptest.vgtest \
nanoleak.stderr.exp nanoleak.vgtest \
nanoleak_supp.stderr.exp nanoleak_supp.vgtest nanoleak.supp \
nanoleak2.stderr.exp nanoleak2.vgtest \
new_nothrow.stderr.exp new_nothrow.vgtest \
new_override.stderr.exp new_override.stdout.exp new_override.vgtest \
null_socket.stderr.exp null_socket.vgtest \
@ -155,7 +156,7 @@ check_PROGRAMS = \
malloc_usable malloc1 malloc2 malloc3 manuel1 manuel2 manuel3 \
match-overrun \
memalign_test memalign2 memcmptest mempool mmaptest \
nanoleak new_nothrow \
nanoleak nanoleak2 new_nothrow \
null_socket oset_test overlap \
partiallydefinedeq \
partial_load pdb-realloc pdb-realloc2 \

View File

@ -0,0 +1,19 @@
// Bruce Lowekamp <lowekamp@sipeerior.com> reported that in a program with a
// reachable leak, if you do:
//
// valgrind --leak-check=yes --gen-suppressions=yes --show-reachable=no -q
//
// it gives the y/n/c suppression prompt for errors that aren't shown. This
// test checks that is fixed.
#include <stdlib.h>
int* a;
int main ( void )
{
a = malloc(1000); // Becomes a reachable leak.
a[0] = 0;
return a[0];
}

View File

View File

@ -0,0 +1,2 @@
vgopts: --leak-check=yes --gen-suppressions=yes --show-reachable=no -q
prog: nanoleak2