This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Got stuck on fork()'s loop when for gcov is used.


I use svn://gcc.gnu.org/svn/gcc/trunk today.

The compiler that i use is one precompiled snapshot GCC-4.2.3-ss-20071031.
$ gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure --prefix=/opt/gcc42320071031 --disable-shared --di
sable-threads --disable-checking --enable-__cxa_atexit --enable-languages=c,c++,
fortran,objc --enable-bootstrap
Thread model: single
gcc version 4.2.3 20071031 (prerelease)

$ export PATH=/opt/gcc42320071031/bin:$PATH

$ export CFLAGS="-O0 -g -fno-omit-frame-pointer -fprofile-arcs -ftest-coverage \
-mno-sse3 -mno-sse2 -mno-sse -mno-mmx -mno-3dnow \
-march=i686 -pipe"

$ mkdir build ; cd build

$ ../configure --prefix=/opt/gcctrunk20071128 \
--disable-shared --disable-threads --enable-checking \
--disable-intl --disable-nls --disable-multilib --enable-libiberty \
--enable-__cxa_atexit --enable-languages=c --disable-bootstrap \
--enable-libssp

$ make "CFLAGS=$CFLAGS"
...
checking for unistd.h... (cached) yes
checking for vfork.h... no
checking for fork... yes
checking for vfork... yes
checking for working fork...   <-- got stuck on loop

$ top
19950 net1      25   0 20612  19m  320 R 80.9  0.6  21:10.03 conftest

$ gcov conftest.c    # without Ctrl-C to make
conftest.gcno:version '403e', prefer '402p'
conftest.gcda:version '403e', prefer version '402p'
File ...../build/./gcc/include-fixed/sys/sysmacros.h'
Lines executed:0.00% of 6
...../build/./gcc/include-fixed/sys/sysmacros.h:creating 'sysmacros.h.gcov'

File 'conftest.c'
Lines executed:50.00% of 4
conftest.c:creating 'conftest.c.gcov'

$ # in conftest.c.gcov appears all "-:" lines except four lines:
...
        -:    0:Runs:1905932                      # <- or possible more
...
        -:    7:      int main ()
        1:    8:      {
        1:    9:        if (fork() < 0)                 # <- suspected fork()
    #####:   10:          exit (1);
    #####:   11:        exit (0);
        -:   12:      }

$ cd build/i686-pc-linux-gnu/libiberty/
$ objdump -S ./conftest > conftest.S

Viewing conftest.S and Ctrl-S "fork()" and "__gcov_fork":

08048a60 <main>:
      # include <unistd.h>
      #endif
      /* Some systems only have a dummy stub for fork() */
      int main ()
      {
...
       if (fork() < 0)
 8048a8d:       e8 ce 3b 00 00          call   804c660 <__gcov_fork>
...
0804c660 <__gcov_fork>:
...
# many lines of C-source ...
...
pid_t
__gcov_fork (void)
{
 804c660:       55                      push   %ebp
 804c661:       89 e5                   mov    %esp,%ebp
 804c663:       53                      push   %ebx
 804c664:       83 ec 04                sub    $0x4,%esp
 804c667:       e8 46 c2 ff ff          call   80488b2 <__i686.get_pc_thunk.bx>
...
  __gcov_flush ();
 804c690:       e8 84 fd ff ff          call   804c419 <__gcov_flush>
 804c695:       8b 83 20 0e 00 00       mov    0xe20(%ebx),%eax
 804c69b:       8b 93 24 0e 00 00       mov    0xe24(%ebx),%edx
 804c6a1:       83 c0 01                add    $0x1,%eax
 804c6a4:       83 d2 00                adc    $0x0,%edx
 804c6a7:       89 83 20 0e 00 00       mov    %eax,0xe20(%ebx)
 804c6ad:       89 93 24 0e 00 00       mov    %edx,0xe24(%ebx)
  return fork ();
 804c6b3:       e8 a8 ff ff ff          call   804c660 <__gcov_fork> #
<- again! loop!
...
 804c6df:       c3                      ret

There are attachments conftest.c.gcov, conftest.S and conftest.c
copied from build/i686-pc-linux-gnu/libiberty/

I think that the bug was from GCC-4.2.3-ss-20071031, not from GCC's trunk.

   J.C.Pizarro

Attachment: conftest.c.gcov
Description: Binary data

Attachment: conftest.S
Description: Binary data

Attachment: conftest.c
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]