GCC Miscompiles Qt 3.1.2 with -O3

Marcus mathpup@mylinuxisp.com
Fri May 16 04:16:00 GMT 2003


I've been trying to compile Qt using GCC 3.3 pre-release from CVS for a while, 
and I've always had problems with Qt and -O3 optimization. I was hoping that 
the problems would fix themselves before the release, but they have not.

GCC 3.2 compiled Qt 3.1.2 with -O3 optimization just fine, and GCC 3.3 
compiles Qt with -O2 optimization just fine. Although an obvious solution is 
simply to use -O2, it doesn't address the underlying problem.

To build Qt with -O3, I changed mkspecs/linux-g++/qmake.conf so that
QMAKE_CLFAGS_RELEASE was set to -O3. Then I build Qt using the recommended 
configure options.

During the build, Qt creates several utility programs, including uic. Then uic 
is used to process some files. At the point in the make where uic is invoked 
with

/home/marcus/src/qt/bin/uic -L /home/marcus/src/qt/plugins editfunctions.ui -o 
editfunctions.h

I get a segfault. Running the above command manually under valgrind, I get the 
output:

==26243== valgrind-1.0.4, a memory error detector for x86 GNU/Linux.
==26243== Copyright (C) 2000-2002, and GNU GPL'd, by Julian Seward.
==26243== Estimated CPU clock rate is 1110 MHz
==26243== For more details, rerun with: -v
==26243==
==26243== Invalid read of size 1
==26243==    at 0x4043AAC1: QApplication::desktopSettingsAware() (in 
/home/marcus/src/qt/lib/libqt-mt.so.3.1.2)
==26243==    by 0x403CCE2E: qt_init(int*, char**, QApplication::Type) (in 
/home/marcus/src/qt/lib/libqt-mt.so.3.1.2)
==26243==    by 0x404350C0: QApplication::construct(int&, char**, 
QApplication::Type) (in /home/marcus/src/qt/lib/libqt-mt.so.3.1.2)
==26243==    by 0x40434E68: QApplication::QApplication(int&, char**, bool) (in 
/home/marcus/src/qt/lib/libqt-mt.so.3.1.2)
==26243==    Address 0x604088D5 is not stack'd, malloc'd or free'd
==26243==
==26243== Syscall param write(buf) contains uninitialised or unaddressable 
byte(s)
==26243==    at 0x40E5A5D4: __libc_write (in /lib/libc.so.6)
==26243==    by 0x40C6A231: _IceTransSocketWrite (in 
/usr/X11R6/lib/libICE.so.6.3)
==26243==    by 0x40C6B0DD: _IceTransWrite (in /usr/X11R6/lib/libICE.so.6.3)
==26243==    by 0x40C61A7C: _IceWrite (in /usr/X11R6/lib/libICE.so.6.3)
==26243==    Address 0x42598DDF is 3 bytes inside a block of size 1024 alloc'd
==26243==    at 0x4004057C: malloc (vg_clientfuncs.c:100)
==26243==    by 0x40C5E5D0: IceOpenConnection (in 
/usr/X11R6/lib/libICE.so.6.3)
==26243==    by 0x40C5230A: SmcOpenConnection (in /usr/X11R6/lib/libSM.so.6.0)
==26243==    by 0x403D4E9C: QSessionManager::QSessionManager(QApplication*, 
QString&, QString&) (in /home/marcus/src/qt/lib/libqt-mt.so.3.1.2)



More information about the Gcc-bugs mailing list