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

            Bug ID: 67097
           Summary: gcov-tool merge (can) crash when dir2 contains files
                    not in dir1
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gilles.gouaillardet at gmail dot com
  Target Milestone: ---

Created attachment 36109
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36109&action=edit
a patch for libgcc/libgcov-util.c

here is the trace of a gcov-tool crash :

$ gcov-tool merge -o merged dir1 dir2
gcov-tool: internal compiler error: in gcov_read_counter_mem, at
../libgcc/libgcov-util.c:490
0x40471f gcov_read_counter_mem()
        ../.././gcc/../libgcc/libgcov-util.c:490
0x409459 gcov_get_counter
        ../.././gcc/../libgcc/libgcov.h:321
0x409493 __gcov_merge_add(long*, unsigned int)
        ../.././gcc/../libgcc/libgcov-merge.c:56
0x4089e1 merge_one_data
        ../.././gcc/../libgcc/libgcov-driver.c:472
0x409235 dump_one_gcov
        ../.././gcc/../libgcc/libgcov-driver.c:788
0x4093ee gcov_do_dump(gcov_info*, int)
        ../.././gcc/../libgcc/libgcov-driver.c:846
0x402e00 gcov_output_files
        ../.././gcc/gcov-tool.c:117
0x402ede profile_merge
        ../.././gcc/gcov-tool.c:154
0x4030e8 do_merge
        ../.././gcc/gcov-tool.c:226
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.


here is the content of dir1 :

$ find dir1 -type f
dir1/opal/mca/common/verbs/.libs/libmca_common_verbs_la-common_verbs_qp_type.gcda

and here is the content of dir2 :

$ find dir2 -type f 
dir2/opal/mca/common/verbs/.libs/libmca_common_verbs_la-common_verbs_qp_type.gcda
dir2/opal/mca/pstat/linux/.libs/pstat_linux_module.gcda
dir2/opal/mca/pstat/linux/.libs/pstat_linux_component.gcda


dir2 contains two files not in dir1.
note that condition is not necessary to trigger the bug, the order in which
files are enumerated also matter.

the attached patch solves the problem.

without it, some files can end up several time in tgt_profile, and i think that
it what is causing the crash

Reply via email to