[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

undetected gprof counter overflow

From: Martien de Jong
Subject: undetected gprof counter overflow
Date: Wed, 26 Aug 2009 12:29:30 +0200
User-agent: Thunderbird (X11/20081113)


I am using gprof

If the entry count of a function has overflowed, I get *very* strange
results without being notified that something is wrong. For instance,
the total cumulative time from flat profile is 2161.29 s, and the graph
profile states:

granularity: each sample hit covers 4 byte(s) for 0.00% of 9803.48 seconds

My theory is this:
Suppose I have a small leaf function f, that is called by tens of
functions, each with a non-overflowing call count. f itself has an entry
count that overflows. I suspect that gprof computes the total time of
f by something like

time(f) =  sum over callers:c {callcount(c) / entrycount(f)} * flattime(f)

Somehow gprof fails to notice that the sum of the callcounts exceeds the
entrycount of f, and comes (in my specific case) with a time(f) that is
more than flattime(f) by a factor of 120 (yes, I have loads
of callers to f). Since this is then accounted for in the importance of
all callers of f, I get profile which is complete nonsense.

In my opinion, time(f) <= flattime(f), always. Moreover, by detecting
violation of this, it should frequently be possible to reconstruct the
(incorrect by overflow) entry count of f, as the total sum of profiled
calls to f. For a fully profiled program this is accurate provided that
the call counts have not overflowed. Even if they have, the results will
make more sense than without correction.

BTW I usually only profile program runs that take long (because they get
noticed). That makes counter overflow be the default case, rather than
the exception.  I appreciate that it is hard to have an efficient mcount
implementation that guards against overflow, but the offline tool should
try very hard to report detectable inconsistencies.

Kind regards,

Martien de Jong, Senior Software Engineer, Associated Compiler Experts bv,
De Ruyterkade 113, 1011 AB  Amsterdam, The Netherlands.
Tel: +31 20 6646416, Fax: +31 20 6750389,
mailto:address@hidden, http://www.ace.nl.
This e-mail and any files transmitted with it are confidential. Any tech-
nical information contained herein is supplied as-is, and no rights can
be derived therefrom. Unless you are the intended recipient, you should
not read, disclose, copy, or otherwise use the information in this message.
If you have received the message in error, please notify the sender by
reply e-mail immediately and delete the message and all copies thereof.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]