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

            Bug ID: 83074
           Summary: Shared object built with `-pie --coverage' hangs
                    forever
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stvar at yahoo dot com
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Created attachment 42664
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42664&action=edit
Source code, Makefile and test scenario

Dear maintainers,

While running the testing suite of one of my projects with coverage
instrumentation enabled, I came across the following issue of GCC:

The short story: a shared object built with `-pie --coverage' hangs
forever somewhere in function 'gcov_do_dump' (most likely in function
'compute_summary') in the file 'libgcc/libgcov-driver.c'.

This happens on a GNU/Linux x86_64 machine with GCC 7.2.0 built from
sources (using a stock GCC 4.3.4):

  $ make GCC=gcc-7.2.0 COVERAGE=yes -B
  gcc-7.2.0 -Wall -Wextra -std=gnu99 -g -I. --coverage -fPIC
-fvisibility=hidden -c foo.c -o foo.o 
  gcc-7.2.0 -Wl,-L. -Wl,--rpath-link=. --coverage -Wl,--export-dynamic -pie
foo.o -o foo.so
  gcc-7.2.0 -Wall -Wextra -std=gnu99 -g -I. --coverage -c bar.c -o bar.o 
  gcc-7.2.0 -Wl,-L. -Wl,--rpath-link=. --coverage -Wl,-rpath=. -l:foo.so -fPIC
bar.o foo.so -o bar

  $ time-out() {
    local d="$1"; shift
    timeout "$d" "$@"
    [ "$?" -eq 124 ] && {
      echo >&2 "command timed out: $@"
      return 1
    }
  }

  $ ./foo.so 
  foo.so: version: 0.1

  $ time-out 8 ./bar 
  bar: foo.so: version: 0.1
  command timed out: ./bar

  $ gdb -q --args ./bar
  Reading symbols from ./bar...done.
  (gdb) run
  Starting program: ./bar 
  bar: foo.so: version: 0.1
  ^C
  Program received signal SIGINT, Interrupt.
  0x00007ffff7bd9012 in gcov_do_dump () from ./foo.so
  (gdb) backtrace
  #0  0x00007ffff7bd9012 in gcov_do_dump () from ./foo.so
  #1  0x00007ffff7bda3f2 in __gcov_exit () from ./foo.so
  #2  0x00007ffff7bd84d9 in _GLOBAL__sub_D_00100_1_foo.c () from ./foo.so
  #3  0x00007ffff7bd83df in __do_global_dtors_aux () from ./foo.so
  #4  0x0000000000000000 in ?? ()

When `-pie' is replaced with `-shared' everything works nice.

Important to mention is that the behavior seen above doesn't occur
with GCC 4.3.4 and 4.8.0 (the only other GCC versions currently at
my disposal).

The story is presented in its entirety in the file 'test.txt' --
bundled within the attached tarball along with the source code
and Makefile that are producing the binaries 'foo.so' and 'bar'.

Sincerely,

Stefan Vargyas.

Reply via email to