The "single" value profiler (gen_one_value_profiler)
can emit values that gcov-io doesn't like to see, namely 
negative values, per this check in gcov_read_counter:

  if (value < 0)
    gcov_var.error = -1;


Testcase:

[brat1]$ cat a.i
# 1 "a.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "a.c"
int j = 1<<31;

main ()
{
 int i;
 for (i = 0; i< 10000000; i++)
  if (! (i % j))
   return;
}

Steps to reproduce.  There is a compile step and a run step since
this is feedback optimization.

[brat1]$ rm -f a.gcda

[brat1]$ xgcc-3.4.3 -v -save-temps  a.c --profile-generate 
Reading specs from /u/nomura/dl/gcc-3.4.3_linux/gcc/specs
Configured with: ../gcc-3.4.3/configure --enable-languages=c,c++
Thread model: posix
gcc version 3.4.3
 /u/nomura/dl/gcc-3.4.3_linux/gcc/cc1 -E -quiet -v -iprefix
/u/nomura/dl/gcc-3.4.3_linux/gcc/../lib/gcc/i686-pc-linux-gnu/3.4.3/ -isystem
/u/nomura/dl/gcc-3.4.3_linux/gcc/include a.c -mtune=pentiumpro
-fprofile-generate -o a.i
ignoring nonexistent directory
"/u/nomura/dl/gcc-3.4.3_linux/gcc/../lib/gcc/i686-pc-linux-gnu/3.4.3/include"
ignoring nonexistent directory
"/u/nomura/dl/gcc-3.4.3_linux/gcc/../lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../i686-pc-linux-gnu/include"
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory 
"/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.3/include"
#include "..." search starts here:
#include <...> search starts here:
 /u/nomura/dl/gcc-3.4.3_linux/gcc/include
 /usr/local/include
 /usr/local/lib/../i686-pc-linux-gnu/include
 /usr/include
End of search list.
 /u/nomura/dl/gcc-3.4.3_linux/gcc/cc1 -fpreprocessed a.i -quiet -dumpbase a.c
-mtune=pentiumpro -auxbase a -version -fprofile-generate -o a.s
GNU C version 3.4.3 (i686-pc-linux-gnu)
        compiled by GNU C version 3.2 20020903 (Red Hat Linux 8.0 3.2-7).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
 as -V -Qy -o a.o a.s
GNU assembler version 2.13.90.0.2 (i386-redhat-linux) using BFD version
2.13.90.0.2 20020802
 /u/nomura/dl/gcc-3.4.3_linux/gcc/collect2 --eh-frame-hdr -m elf_i386
-dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o
/u/nomura/dl/gcc-3.4.3_linux/gcc/crtbegin.o -L/u/nomura/dl/gcc-3.4.3_linux/gcc
-L/usr/local/lib a.o -lgcov -lgcc -lgcc_eh -lc -lgcc -lgcc_eh
/u/nomura/dl/gcc-3.4.3_linux/gcc/crtend.o /usr/lib/crtn.o


[brat1]$ a.out
profiling:/u/nomura/tools/pbo/value_profiling/a.gcda:Overflow writing
[brat1]$ 

gcov-io is choking on the negative value which the value profiler
tracks in its histogram.  Here's another way to see that:

[brat1]$ ~/dl/gcc-3.4.2_linux/gcc/gcov-dump -l a.gcda
a.gcda:data:magic `gcda':version `304*'
a.gcda:stamp 1797859630
a.gcda: 01000000:   2:FUNCTION ident=3, checksum=0x92e25e42
a.gcda:  01a10000:   6:COUNTERS arcs 3 counts
a.gcda:         0 1 0 0
a.gcda:  01a70000:   6:COUNTERS single 3 counts
a.gcda:         0 -2147483648 1 1
a.gcda:counter overflow at 23
a.gcda:early end of file
[brat1]$

-- 
           Summary: value profiling gets "Overflow writing"
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nomura at netapp dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20310

Reply via email to