compiled program segfault when -O0 is used to compile

Bug #591819 reported by Kaylee Hirsch
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
gcc-defaults
Invalid
Medium
gcc-defaults (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

I don't know whether this is really a problem, or what not, but I'm attaching logs, and the program which causes it, along with every detail I can think of. When I compile my code, if I compile it -O2, it compiles and runs fine. if I compile it with -O0, it segfaults very early on in the execution. I've made no changes to anything in between compiles.

Compiling the code successfully requires the following libraries:
opengl (mesa)
glut (freeglut)
curl
FTGL (patched, see https://bugs.launchpad.net/ubuntu/+source/ftgl/+bug/485225 )

procedure is as follows:

./configure
make CFLAGS="-O0"
src/altocumulus

make clean
make CFLAGS="-O2"
src/altocumulus

My code is pretty crappy, please ignore that, I'm still learning the basics of C.
Regardless, the code shouldn't work with one level of optimization and fail with another.

ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: gcc 4:4.4.3-1ubuntu1
ProcVersionSignature: Ubuntu 2.6.32-22.36-generic 2.6.32.11+drm33.2
Uname: Linux 2.6.32-22-generic x86_64
NonfreeKernelModules: nvidia
Architecture: amd64
Date: Wed Jun 9 11:43:21 2010
EcryptfsInUse: Yes
InstallationMedia: Ubuntu 9.10 "Karmic Koala" - Release amd64 (20091027)
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.utf8
 SHELL=/bin/bash
SourcePackage: gcc-defaults

Revision history for this message
Kaylee Hirsch (techyshishy) wrote :
Revision history for this message
Kaylee Hirsch (techyshishy) wrote :
Revision history for this message
Kaylee Hirsch (techyshishy) wrote :
Revision history for this message
eviom (eviom) wrote :

I have the same problem on both ubuntu 10.04 (not updated, gcc 4.4.3) and ubuntu 11.04 (fully updated, can't check the gcc version right now). According to gdb it crashes in some TFGlyth member function. I really did not expect such problem from gcc...
BTW thanks for the solution, I thought the problem was somwhere in my code.

Changed in gcc-defaults (Ubuntu):
status: New → Confirmed
Revision history for this message
In , eviom (eviom) wrote :

Original thread: https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/591819

When I compile my code, if I compile it -O2, it compiles and runs fine. if I compile it with -O0, it segfaults while rendering text with FTGL. I've made no changes to anything in between compiles. Same FTGL code works fine in win32 (vs2010).

Revision history for this message
eviom (eviom) wrote :

I have submitted it to gcc bugzilla. Here is the thread link:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50239

Revision history for this message
In , Paolo-carlini (paolo-carlini) wrote :

Please follow the normal bug reporting instructions:

  http://gcc.gnu.org/bugs/#report

Changed in gcc-defaults:
importance: Unknown → Medium
status: Unknown → Incomplete
Revision history for this message
In , eviom (eviom) wrote :

When I compile my code, if I compile it -O2, it compiles and runs fine. if I
compile the code without it, my program segfaults while rendering text with FTGL. I've made no changes to anything in between compiles. Same FTGL code works fine in win32 (vs2010).

system: ubuntu 11.04 & 10.04
gcc version: 4.5.2 (from deb package)
command line: gcc -I /usr/include/freetype2 -o ~/BlocksWorld/BlocksWorld Src/*.cpp Src/Linux/*.cpp Src/GUI/*.cpp -lpng -lGL -lGLU -lftgl

Revision history for this message
In , Redi (redi) wrote :

There's no need to repeat the same info you already provided, please provide what you _didn't_ provide, as requested by http://gcc.gnu.org/bugs/#report

we need preprocessed source, and preferably a minimal testcase that has been reduced to the smallest example that still shows the problem

Revision history for this message
In , Paolo-carlini (paolo-carlini) wrote :

Feedback not forthcoming.

Changed in gcc-defaults:
status: Incomplete → Invalid
Revision history for this message
Matthias Klose (doko) wrote :

no feedback

Changed in gcc-defaults (Ubuntu):
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.