Bug 112678

Summary: gcc -O2 hangs compiler
Product: [Fedora] Fedora Reporter: Gene Czarcinski <gczarcinski>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 1CC: 64bit_fedora
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: 3.3.2-6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-10-02 18:12:43 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
network.i without the -O2 parameter
none
network.i when -O2 specified and gcc hangs none

Description Gene Czarcinski 2003-12-27 21:52:33 UTC
Description of problem:
I am attempting the build the libnessus (one of three nessus packages)
on my Opteron system.  These are the 2.0.9 version of nessus.  I can
make the package(s) available (via ftp) if you need them.

These packages build, install and run properly on i386.
When I attempt to build libnessus (nessus-libraries) on x86_64, the
gcc compiler hangs compiling network.c.

In an attempt to narrow the problem, I ran things manually after doing
rpmbuild -bp -- run ./configure and make with the same operands as in
the spec file.

I have narrows the problem to compiling with "-O2" -- without this,
the compile is OK ... with it, the compiler hangs.

If I use gcc32 to compile network.c, the compile does not hang
although I get some warning messages about "cast from pointer to
integer of different size" so I am not sure just how good the result
is anyway ... mmm, I get the same warnings if I compile using gcc
3.3.2 but without -O2 (just no hang).

Version-Release number of selected component (if applicable):
Fedora Core 1 x86_64 preview
gcc 3.3.2-2

How reproducible:
every time



NOTE:  I tried to assign to 64bit_fedora but bugzilla
would not accept that.

Comment 1 Jakub Jelinek 2003-12-27 22:00:44 UTC
Please attach preprocessed network.i (add -save-temps option to gcc
when compiling network.c) and write what exact other compiler flags
you've used to make it hang.

Comment 2 Gene Czarcinski 2003-12-27 22:29:30 UTC
The only parameter difference is -O2.  Here are the two command line
entries:

with -O2:
 
gcc -pipe -I../ -DHAVE_CONFIG_H -DNESSUS_ON_SSL -I.
-I/usr/kerberos/include -DHAVE_SSL -I/usr/include/openssl
-I/home/genec/devel/redhat/BUILD/nessus-libraries/include
-I/home/genec/devel/redhat/BUILD/nessus-libraries/libpcap-nessus -g
-O2 -save-temps  -pipe -c network.c  -fPIC -DPIC -o .libs/network.lo
 
without -O2:
gcc -pipe -I../ -DHAVE_CONFIG_H -DNESSUS_ON_SSL -I.
-I/usr/kerberos/include -DHAVE_SSL -I/usr/include/openssl
-I/home/genec/devel/redhat/BUILD/nessus-libraries/include
-I/home/genec/devel/redhat/BUILD/nessus-libraries/libpcap-nessus -g
-save-temps  -pipe -c network.c  -fPIC -DPIC -o .libs/network.lo

Since the network.i output is different for the -O2 and non-O2 cases,
I am attaching both.



Comment 3 Gene Czarcinski 2003-12-27 22:30:57 UTC
Created attachment 96708 [details]
network.i without the -O2 parameter

Comment 4 Gene Czarcinski 2003-12-27 22:32:12 UTC
Created attachment 96709 [details]
network.i when -O2 specified and gcc hangs

Comment 5 Gene Czarcinski 2003-12-29 12:02:01 UTC
I ran some additional tests.

Using the general form of "gcc -c -o xxx" and either of the attached
files ..

With nothing or -O1 specified, it takes about 1 second to compile.

With -O2, -O3, or -Os, the compile hangs.

Comment 6 Gene Czarcinski 2003-12-29 14:03:18 UTC
The compile (-O2) also works OK when these files are compiled on a
dual Athlon for the network.i generated by -O2 on the Opteron x86_64
system.

Comment 7 Jakub Jelinek 2003-12-29 15:34:35 UTC
Simplified to:
extern int f1 (int, void *);
extern int *f2 (void) __attribute__ ((__const__));
extern int f3 (int, void *);

int
test (int x, char *y, int z)
{
  int b = 0;

  if (x < 1024)
    {
      y[0] = '\0';

      do
        {
          switch (f1 (x, y + b))
            {
            case -1:
              if (b == 0)
                return -1;
              else
                return b;

            default:
              b++;
            }
        }
      while (y[b - 1] != '\0' && y[b - 1] != '\n' && b < z);
    }
  else
    {
      do
        {
          switch (f3 (x, y + b))
            {
            case -1:
              if ((*f2 ()) == 4)
                continue;
              if (b == 0)
                return -1;
              else
                return b;

            default:
              b++;
            }
        }
      while (y[b - 1] != '\0' && y[b - 1] != '\n' && b < z);
    }
  return b;
}

Comment 8 Jakub Jelinek 2003-12-30 15:22:09 UTC
http://gcc.gnu.org/PR13521

Comment 10 Gene Czarcinski 2004-01-08 01:19:51 UTC
1. patch works!

I took the 3.3.2-5 version of src.rpm, applied the patch (after some
fiddling but no real changes), rebuilt all of gcc and installed.  Then
I ran the rpmbuild for libnessus which had hung and it not compiles
just fine.

2.  I would appreciate it if this patch could be installed into a
"development" version of gcc since that will make it easier to
incorporate into the x86_64 version of FC1 (as an update if not in the
base).

Thanks Jakub!

Now I need to play with the nessus rpms to get it to properly handle
being on a x86_64 system (/usr/lib64, etc).

Comment 11 Gene Czarcinski 2004-01-08 01:20:52 UTC
not => now

Comment 12 Justin M. Forbes 2004-02-04 20:16:05 UTC
Was this patch added to the current release or testing release? 

Comment 13 Gene Czarcinski 2004-02-04 20:50:41 UTC
I applied the above patch to gcc-3-3-2-5 and rebuild ... it fixed the
problem.

This fix has been incorporated into gcc-3.3.2-6 (last seen in
development).  I have since rebuilt gcc-3.3.2-6 (src.rpm from
development) for the x86_64 and installed it ... it also fixes the
loop problem.

I see that development currently has gcc-3.3.2-8 (which probably works
but I have not tried it).

The binaries I did are on ftp://czarc.net/pub/x86_64 ... if you need
the 3.3.2-6 src.rpm, I can upload it.

When I get a change, I will rebuild to gcc-3.3.2-8.

BTW, you need glibc-devel for the i386(!!) to build gcc.  Since that
is true, it probably should be part of the distribution.