public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: macklobell@hotmail.com
To: gcc-gnats@gcc.gnu.org
Subject: c/9185: gcc produces errornous code on cygwin host when -fomit-frame-pointer is used together with -O2 or -O3
Date: Mon, 06 Jan 2003 13:36:00 -0000	[thread overview]
Message-ID: <20030106133124.14481.qmail@sources.redhat.com> (raw)


>Number:         9185
>Category:       c
>Synopsis:       gcc produces errornous code on cygwin host when -fomit-frame-pointer is used together with -O2 or -O3
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 06 05:36:20 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     macklobell@hotmail.com
>Release:        All
>Organization:
>Environment:
$ uname -a
CYGWIN_NT-5.1 VOLVO 1.3.18(0.69/3/2) 2002-12-25 15:37 i686 unknown unknown Cygwin

$ echo $CC33
/home/lobell/build/native_gcc3.3/gcc/xgcc.exe -B /home/lobell/build/native_gcc3.3/gcc

$ $CC33 --version
xgcc (GCC) 3.3 20030103 (prerelease)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ as --version
GNU assembler 2.13.90 20021118
Copyright 2002 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.
This assembler was configured for a target of `i686-pc-cygwin'.

$ ld --version
GNU ld version 2.13.90 20021118
Copyright 2002 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.
>Description:
I came a cross this problem when building binutils. All logs/traces are from builds of the linker (ld.exe).

The problem, if i build the linker with "-fomit-frame-pointer" together with -O2 or -O3 the executable will crash (segmentation fault). ld.exe always crash in the function parse_args(lexsup.c), so all logs attached are from that file.

This might only be a cygwin problem. I did the same tests o n a FreeBSD machine and the executables work fine there.

*** Working testcase. -fomit-frame-pointer with -O1 ***

$ rm lexsup.[ios]; make CC="$CC33" CFLAGS="-g -O1 -fomit-frame-pointer -save-temps -dAP -Wa,-al
h=mixed.log" && ./ld-new.exe -V
make  all-recursive
make[1]: Entering directory `/home/lobell/build/native_binutils/ld'
Making all in po
make[2]: Entering directory `/home/lobell/build/native_binutils/ld/po'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/lobell/build/native_binutils/ld/po'
make[2]: Entering directory `/home/lobell/build/native_binutils/ld'
/home/lobell/build/native_gcc3.3/gcc/xgcc.exe -B /home/lobell/build/native_gcc3.3/gcc -DHAVE_CON
FIG_H -I. -I../../../src/binutils-2.13.1/ld -I. -D_GNU_SOURCE -I. -I../../../src/binutils-2.13.1
/ld -I../bfd -I../../../src/binutils-2.13.1/ld/../bfd -I../../../src/binutils-2.13.1/ld/../inclu
de -I../../../src/binutils-2.13.1/ld/../intl -I../intl  -g -O1 -fomit-frame-pointer -save-temps
-dAP -Wa,-alh=mixed.log -DLOCALEDIR="\"/usr/local/share/locale\""   -W -Wall -Wstrict-prototypes
 -Wmissing-prototypes -g -O1 -fomit-frame-pointer -save-temps -dAP -Wa,-alh=mixed.log -c ../../.
./src/binutils-2.13.1/ld/lexsup.c
/bin/sh ./libtool --mode=link /home/lobell/build/native_gcc3.3/gcc/xgcc.exe -B /home/lobell/buil
d/native_gcc3.3/gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O1 -fomit-frame-pointe
r -save-temps -dAP -Wa,-alh=mixed.log  -o ld-new.exe  ldgram.o ldlex.o lexsup.o ldlang.o mri.o l
dctor.o ldmain.o ldwrite.o ldexp.o ldemul.o ldver.o ldmisc.o ldfile.o ldcref.o ei386pe.o deffile
p.o pe-dll.o ../bfd/libbfd.la ../libiberty/libiberty.a
/home/lobell/build/native_gcc3.3/gcc/xgcc.exe -B /home/lobell/build/native_gcc3.3/gcc -W -Wall -
Wstrict-prototypes -Wmissing-prototypes -g -O1 -fomit-frame-pointer -save-temps -dAP -Wa,-alh=mi
xed.log -o ld-new.exe ldgram.o ldlex.o lexsup.o ldlang.o mri.o ldctor.o ldmain.o ldwrite.o ldexp
.o ldemul.o ldver.o ldmisc.o ldfile.o ldcref.o ei386pe.o deffilep.o pe-dll.o  ../bfd/.libs/libbf
d.a ../libiberty/libiberty.a
make[2]: Leaving directory `/home/lobell/build/native_binutils/ld'
make[1]: Leaving directory `/home/lobell/build/native_binutils/ld'
GNU ld version 2.13.1                   <- *** Working! ***
  Supported emulations:
   i386pe

*** Not working testcase. -fomit-frame-pointer with -O2 ***

$ rm lexsup.[ios]; make CC="$CC33" CFLAGS="-g -O2 -fomit-frame-pointer -save-temps -dAP -Wa,-al
h=mixed.log" && ./ld-new.exe -V
make  all-recursive
make[1]: Entering directory `/home/lobell/build/native_binutils/ld'
Making all in po
make[2]: Entering directory `/home/lobell/build/native_binutils/ld/po'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/lobell/build/native_binutils/ld/po'
make[2]: Entering directory `/home/lobell/build/native_binutils/ld'
/home/lobell/build/native_gcc3.3/gcc/xgcc.exe -B /home/lobell/build/native_gcc3.3/gcc -DHAVE_CON
FIG_H -I. -I../../../src/binutils-2.13.1/ld -I. -D_GNU_SOURCE -I. -I../../../src/binutils-2.13.1
/ld -I../bfd -I../../../src/binutils-2.13.1/ld/../bfd -I../../../src/binutils-2.13.1/ld/../inclu
de -I../../../src/binutils-2.13.1/ld/../intl -I../intl  -g -O2 -fomit-frame-pointer -save-temps
-dAP -Wa,-alh=mixed.log -DLOCALEDIR="\"/usr/local/share/locale\""   -W -Wall -Wstrict-prototypes
 -Wmissing-prototypes -g -O2 -fomit-frame-pointer -save-temps -dAP -Wa,-alh=mixed.log -c ../../.
./src/binutils-2.13.1/ld/lexsup.c
/bin/sh ./libtool --mode=link /home/lobell/build/native_gcc3.3/gcc/xgcc.exe -B /home/lobell/buil
d/native_gcc3.3/gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2 -fomit-frame-pointe
r -save-temps -dAP -Wa,-alh=mixed.log  -o ld-new.exe  ldgram.o ldlex.o lexsup.o ldlang.o mri.o l
dctor.o ldmain.o ldwrite.o ldexp.o ldemul.o ldver.o ldmisc.o ldfile.o ldcref.o ei386pe.o deffile
p.o pe-dll.o ../bfd/libbfd.la ../libiberty/libiberty.a
/home/lobell/build/native_gcc3.3/gcc/xgcc.exe -B /home/lobell/build/native_gcc3.3/gcc -W -Wall -
Wstrict-prototypes -Wmissing-prototypes -g -O2 -fomit-frame-pointer -save-temps -dAP -Wa,-alh=mi
xed.log -o ld-new.exe ldgram.o ldlex.o lexsup.o ldlang.o mri.o ldctor.o ldmain.o ldwrite.o ldexp
.o ldemul.o ldver.o ldmisc.o ldfile.o ldcref.o ei386pe.o deffilep.o pe-dll.o  ../bfd/.libs/libbf
d.a ../libiberty/libiberty.a
make[2]: Leaving directory `/home/lobell/build/native_binutils/ld'
make[1]: Leaving directory `/home/lobell/build/native_binutils/ld'
Segmentation fault (core dumped)        <- *** NOTE! ***


*** Not working testcase. -fomit-frame-pointer and -O3 ***

$ rm lexsup.[ios]; make CC="$CC33" CFLAGS="-g -O3 -fomit-frame-pointer -save-temps -dAP -Wa,-al
h=mixed.log" && ./ld-new.exe -V
make  all-recursive
make[1]: Entering directory `/home/lobell/build/native_binutils/ld'
Making all in po
make[2]: Entering directory `/home/lobell/build/native_binutils/ld/po'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/lobell/build/native_binutils/ld/po'
make[2]: Entering directory `/home/lobell/build/native_binutils/ld'
/home/lobell/build/native_gcc3.3/gcc/xgcc.exe -B /home/lobell/build/native_gcc3.3/gcc -DHAVE_CON
FIG_H -I. -I../../../src/binutils-2.13.1/ld -I. -D_GNU_SOURCE -I. -I../../../src/binutils-2.13.1
/ld -I../bfd -I../../../src/binutils-2.13.1/ld/../bfd -I../../../src/binutils-2.13.1/ld/../inclu
de -I../../../src/binutils-2.13.1/ld/../intl -I../intl  -g -O3 -fomit-frame-pointer -save-temps
-dAP -Wa,-alh=mixed.log -DLOCALEDIR="\"/usr/local/share/locale\""   -W -Wall -Wstrict-prototypes
 -Wmissing-prototypes -g -O3 -fomit-frame-pointer -save-temps -dAP -Wa,-alh=mixed.log -c ../../.
./src/binutils-2.13.1/ld/lexsup.c
/bin/sh ./libtool --mode=link /home/lobell/build/native_gcc3.3/gcc/xgcc.exe -B /home/lobell/buil
d/native_gcc3.3/gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O3 -fomit-frame-pointe
r -save-temps -dAP -Wa,-alh=mixed.log  -o ld-new.exe  ldgram.o ldlex.o lexsup.o ldlang.o mri.o l
dctor.o ldmain.o ldwrite.o ldexp.o ldemul.o ldver.o ldmisc.o ldfile.o ldcref.o ei386pe.o deffile
p.o pe-dll.o ../bfd/libbfd.la ../libiberty/libiberty.a
/home/lobell/build/native_gcc3.3/gcc/xgcc.exe -B /home/lobell/build/native_gcc3.3/gcc -W -Wall -
Wstrict-prototypes -Wmissing-prototypes -g -O3 -fomit-frame-pointer -save-temps -dAP -Wa,-alh=mi
xed.log -o ld-new.exe ldgram.o ldlex.o lexsup.o ldlang.o mri.o ldctor.o ldmain.o ldwrite.o ldexp
.o ldemul.o ldver.o ldmisc.o ldfile.o ldcref.o ei386pe.o deffilep.o pe-dll.o  ../bfd/.libs/libbf
d.a ../libiberty/libiberty.a
make[2]: Leaving directory `/home/lobell/build/native_binutils/ld'
make[1]: Leaving directory `/home/lobell/build/native_binutils/ld'
Segmentation fault (core dumped)        <- *** NOTE! ***

*** gdb output ***

$ /usr/local/native/bin/gdb.exe ./ld-new.exe
GNU gdb 5.3
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-cygwin"...
(gdb) r
Starting program: /home/lobell/build/native_binutils/ld/ld-new.exe

Program received signal SIGSEGV, Segmentation fault.
parse_args (argc=Cannot access memory at address 0x1051
) at ../../../src/binutils-2.13.1/ld/lexsup.c:492
492                                 longopts[il] = ld_options[i].opt;
(gdb) where
#0  parse_args (argc=Cannot access memory at address 0x1051
) at ../../../src/binutils-2.13.1/ld/lexsup.c:492
#1  0x77fa2aef in _libkernel32_a_iname ()
Cannot access memory at address 0x1
(gdb)


I have done these tests with 3.3, 3.4 and 3.2, and the problem exists in all versions.

I have attached the following files from a build with CFLAGS="-fomit-frame-pointer -O2":
lexsup.s    (-save-temps -dAP)
mixed.log   (-Wa,-alh=mixed.log)
lexsup.c
>How-To-Repeat:
Build binutils 2.13.1 on a cygwin host with CFLAGS="-fomit-frame-pointer -O2".
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2003-01-06 13:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-06 13:36 macklobell [this message]
2003-01-06 21:06 Danny Smith
2003-01-06 22:46 Mack Lobell
2003-01-07  1:04 bangerth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030106133124.14481.qmail@sources.redhat.com \
    --to=macklobell@hotmail.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).