From: Philippe Waroquiers Date: Sun, 27 Jan 2019 12:12:42 +0000 (+0100) Subject: Fix callgrind_annotate Use of uninitialized value in numeric gt (>) X-Git-Tag: VALGRIND_3_15_0~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e911f75ee348e90c3c33e6cc4a9c79fbdad51232;p=thirdparty%2Fvalgrind.git Fix callgrind_annotate Use of uninitialized value in numeric gt (>) 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 '.'. --- diff --git a/NEWS b/NEWS index 741fa601ec..7014fb038d 100644 --- 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) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/callgrind/callgrind_annotate.in b/callgrind/callgrind_annotate.in index 14b115356b..beb86b88f3 100644 --- a/callgrind/callgrind_annotate.in +++ b/callgrind/callgrind_annotate.in @@ -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]);