public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "slyfox at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug gcov-profile/96913] gcc-11: __gcov_merge_topn hangs
Date: Sun, 06 Sep 2020 10:23:16 +0000	[thread overview]
Message-ID: <bug-96913-4-E7lkiFiQ3V@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96913-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96913

--- Comment #4 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
(In reply to Sergei Trofimovich from comment #3)
> Specifically I think this is already a wrong format on disk:
> 
> > _json.gcda:    01a70000:   0:COUNTERS topn 0 counts
> > _json.gcda:    01a90000:  48:COUNTERS indirect_call 24 counts
> > _json.gcda:                   0: 1 1 140325305737168 1 1 140325305737200 0 0
> > _json.gcda:                   8: 0 0 0 0 0 0 0 0
> > _json.gcda:                  16: 0 0 0 0 0 0 0 0
> > ...
> 
> Assuming indirect_call is in a 'hist' value format it should  be in form of:
> 
>   [total_executions, N, value1, counter1, ..., valueN, counterN]
> 
> Main problem: we have more than one entry here (which might be ok):
> - record1 (ok):  total_executions=1 N=1 value1=140325305737168 counter1=1
> - record2 (bad): total_executions=1 N=140325305737200 counter=0 ...
> 
> This is where we trip over enormous N.

Found one of the causes of profiling data corruption. The bug happened earlier
on initial serialization of indirect counters functions. The problematic code
is:

https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/libgcov-driver.c;h=58914268d4ece0b3a3a7dcb9cb21c4fa197fd770;hb=HEAD#l427

"""
 417       ci_ptr = gfi_ptr->ctrs;
 418       for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
 419         {
 420           gcov_position_t n_counts;
 421 
 422           if (!gi_ptr->merge[t_ix])
 423             continue;
 424 
 425           n_counts = ci_ptr->num;
 426 
 427           if (gi_ptr->merge[t_ix] == __gcov_merge_topn)
 428             write_top_counters (ci_ptr, t_ix, n_counts);
 429           else
 430             {
 431               /* Do not stream when all counters are zero.  */
 432               int all_zeros = 1;
 433               for (unsigned i = 0; i < n_counts; i++)
 434                 if (ci_ptr->values[i] != 0)
 435                   {
 436                     all_zeros = 0;
 437                     break;
 438                   }
"""

The problematic line here is 'if (gi_ptr->merge[t_ix] == __gcov_merge_topn)'.

In case of tauthon '__gcov_merge_topn' is defined in two places:
1. in 'tauthon' binary itself
2. in any other shared library loaded by tauthon. Looks like
'libtauthon2.8.so.1.0' is the first one.

'__gcov_merge_topn' is defined as hidden symbol and gets resolved to local
symbol:

$ x86_64-pc-linux-gnu-nm tauthon | fgrep gcov_merge_top
000000000040387f t __gcov_merge_topn
$ x86_64-pc-linux-gnu-nm libtauthon2.8.so.1.0 | fgrep gcov_merge_top
000000000029a202 t __gcov_merge_topn

Don't know yet know where 'gi_ptr->merge' gets filled in to leak executable's
symbol into binary.

  parent reply	other threads:[~2020-09-06 10:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03  7:39 [Bug gcov-profile/96913] New: " slyfox at gcc dot gnu.org
2020-09-03  7:41 ` [Bug gcov-profile/96913] " slyfox at gcc dot gnu.org
2020-09-04 15:26 ` slyfox at gcc dot gnu.org
2020-09-04 21:31 ` slyfox at gcc dot gnu.org
2020-09-06 10:23 ` slyfox at gcc dot gnu.org [this message]
2020-09-06 11:25 ` slyfox at gcc dot gnu.org
2020-09-06 11:31 ` [Bug gcov-profile/96913] [10/11 regression] gcov TOPN streaming is incorrect for shared libraries slyfox at gcc dot gnu.org
2020-09-22 10:42 ` cvs-commit at gcc dot gnu.org
2020-09-22 10:44 ` [Bug gcov-profile/96913] [10 " slyfox at gcc dot gnu.org
2020-10-02 10:04 ` slyfox at gcc dot gnu.org
2020-10-02 12:30 ` cvs-commit at gcc dot gnu.org
2020-10-02 12:32 ` slyfox at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-96913-4-E7lkiFiQ3V@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).