]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Count error contexts properly in VG_(unique_error). Avoids the problem seen
authorNicholas Nethercote <njn@valgrind.org>
Tue, 11 Aug 2009 00:52:40 +0000 (00:52 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Tue, 11 Aug 2009 00:52:40 +0000 (00:52 +0000)
of "5 errors from 0 contexts" with leak errors.

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

NEWS
coregrind/m_errormgr.c
memcheck/mc_leakcheck.c

diff --git a/NEWS b/NEWS
index ae5c031cf173dd52d99a6532ddb7827ec459cac7..3b06382b9c2560c1a81587a003604f5b6647d360 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -77,6 +77,10 @@ Release 3.5.0 (???)
   - The default value for the --leak-resolution option has been changed from
     "low" to "high".  In general, this means that more leak reports will be
     produced, but each leak report will describe fewer leaked blocks.
+  - "Definitely lost" and "possibly lost" leaks are now considered as normal
+    errors, ie. they are counted for the "ERROR SUMMARY" and
+    --error-exitcode.  This is true even if their loss records aren't
+    printed, ie. if you run with --leak-check=summary.
   - The documentation for the leak checker has also been improved.
 
 * XXX: Atomic instructions are now handled properly...
index 41918357cce03fad73ccca5a8d44b90e50e4fc68..b026df4a56092bd2317fce2e3cb9ba5d167d885c 100644 (file)
@@ -79,6 +79,13 @@ static UInt n_errs_found = 0;
 /* Running count of suppressed errors detected. */
 static UInt n_errs_suppressed = 0;
 
+/* Running count of unsuppressed error contexts. */
+static UInt n_err_contexts = 0;
+
+/* Running count of suppressed error contexts. */
+static UInt n_supp_contexts = 0;
+
+
 /* forwards ... */
 static Supp* is_suppressible_error ( Error* err );
 
@@ -712,6 +719,7 @@ void VG_(maybe_record_error) ( ThreadId tid,
    p->supp = is_suppressible_error(&err);
    errors  = p;
    if (p->supp == NULL) {
+      n_err_contexts++;
       n_errs_found++;
       /* A bit of prettyprinting, to ensure there's a blank line
          in between each error. */
@@ -727,6 +735,7 @@ void VG_(maybe_record_error) ( ThreadId tid,
       is_first_shown_context = False;
       n_errs_shown++;
    } else {
+      n_supp_contexts++;
       n_errs_suppressed++;
       p->supp->count++;
    }
@@ -760,8 +769,10 @@ Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind, Addr a, Char* s,
 
    su = is_suppressible_error(&err);
    if (NULL == su) {
-      if (count_error)
+      if (count_error) {
          n_errs_found++;
+         n_err_contexts++;
+      }
 
       if (print_error) {
          /* A bit of prettyprinting, to ensure there's a blank line
@@ -782,6 +793,7 @@ Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind, Addr a, Char* s,
 
    } else {
       n_errs_suppressed++;
+      n_supp_contexts++;
       su->count++;
       return True;
    }
@@ -833,28 +845,13 @@ static Bool show_used_suppressions ( void )
 void VG_(show_all_errors) ( void )
 {
    Int    i, n_min;
-   Int    n_err_contexts, n_supp_contexts;
    Error *p, *p_min;
-   Supp  *su;
    Bool   any_supp;
 
    if (VG_(clo_verbosity) == 0)
       return;
 
-   n_err_contexts = 0;
-   for (p = errors; p != NULL; p = p->next) {
-      if (p->supp == NULL)
-         n_err_contexts++;
-   }
-
-   n_supp_contexts = 0;
-   for (su = suppressions; su != NULL; su = su->next) {
-      if (su->count > 0)
-         n_supp_contexts++;
-   }
-
-   /* If we're printing XML, just show the suppressions and stop.
-    */
+   /* If we're printing XML, just show the suppressions and stop. */
    if (VG_(clo_xml)) {
       (void)show_used_suppressions();
       return;
index 68b317e1ada878b92c2dda7d5f1d33fdd90bd485..0b8ea013f440d7cd43dd92c733234ea8de0f9692 100644 (file)
@@ -842,6 +842,9 @@ static void print_results(ThreadId tid, Bool is_full_check)
       // includes indirectly lost blocks!
       //
       lr = lr_array[i];
+      // You could argue that indirect leaks should be counted as errors, but
+      // it seems better to make the counting criteria similar to the printing
+      // criteria.  So we don't count them.
       count_as_error = Unreached == lr->key.state || 
                        Possible  == lr->key.state;
       print_record = is_full_check &&