]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix callgrind_annotate Use of uninitialized value in numeric gt (>)
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 27 Jan 2019 12:12:42 +0000 (13:12 +0100)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 27 Jan 2019 12:12:42 +0000 (13:12 +0100)
When a callgrind dump file contains no event (at all I think),
then callgrind_annotate can produce the below error messages:
Ir sysCount sysTime  file:function
--------------------------------------------------------------------------------
Use of uninitialized value in numeric gt (>) at ../trunk_untouched/Inst/bin/callgrind_annotate line 957.
Use of uninitialized value in numeric gt (>) at ../trunk_untouched/Inst/bin/callgrind_annotate line 957.
Use of uninitialized value in numeric gt (>) at ../trunk_untouched/Inst/bin/callgrind_annotate line 957.
 .        .       .  /build/glibc-yWQXbR/glibc-2.24/csu/../csu/libc-start.c:(below main) [/lib/x86_64-linux-gnu/libc-2.24.so]
Use of uninitialized value in numeric gt (>) at ../trunk_untouched/Inst/bin/callgrind_annotate line 957.
Use of uninitialized value in numeric gt (>) at ../trunk_untouched/Inst/bin/callgrind_annotate line 957.
Use of uninitialized value in numeric gt (>) at ../trunk_untouched/Inst/bin/callgrind_annotate line 957.
 .        .       .  /build/glibc-yWQXbR/glibc-2.24/elf/../sysdeps/x86_64/dl-trampoline.h:_dl_runtime_resolve_xsave [/lib/x86_64-linux-gnu/ld-2.24.so]
Use of uninitialized value in numeric gt (>) at ../trunk_untouched/Inst/bin/callgrind_annotate line 957.
.....

The above can be produced by:
  run sleep 100 under callgrind.
  take some callgrind dumps after the startup.
  ./Inst/bin/callgrind_annotate --threshold=1  callgrind.out.31377.2

Check that the value is defined before doing the comparison.

Note: callgrind_annotate shows functions which have undefined costs
for all events (and I guess it would also show functions that have zero
costs for all events).
Maybe it would be better to not show at all such functions, rather than
show them with all '.'.

NEWS
callgrind/callgrind_annotate.in

diff --git a/NEWS b/NEWS
index 741fa601ec8541b5ad9532599338512369862d60..7014fb038de378b2fef5bc264c8e95e43a7e6d76 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -92,6 +92,7 @@ where XXXXXX is the bug number as listed below.
 n-i-bz  add syswrap for PTRACE_GET|SET_THREAD_AREA on amd64.
 n-i-bz  Fix callgrind_annotate non deterministic order for equal total
 n-i-bz  callgrind_annotate --threshold=100 does not print all functions.
+n-i-bz  callgrind_annotate Use of uninitialized value in numeric gt (>)
 
 Release 3.14.0 (9 October 2018)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index 14b115356bfe211f68bafec35fda1e5c0772b326..beb86b88f3c39a99dad634bd301c499b8f416643 100644 (file)
@@ -954,7 +954,8 @@ sub print_summary_and_fn_totals ()
             my $reached_all_thresholds = 1;
             foreach my $i (0 .. scalar @thresholds - 1) {
                 my $prop = $curr_totals[$i] * 100;
-                if ($summary_CC->[$sort_order[$i]] >0) {
+                if (defined $summary_CC->[$sort_order[$i]] &&
+                    $summary_CC->[$sort_order[$i]] >0) {
                     $prop = $prop / $summary_CC->[$sort_order[$i]];
                 }
                 $reached_all_thresholds &&= ($prop >= $thresholds[$i]);