Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 335185 - sys-devel/gcc-4.5.1 miscompiles dev-db/mysql on x86 w/-fomit-frame-pointer
Summary: sys-devel/gcc-4.5.1 miscompiles dev-db/mysql on x86 w/-fomit-frame-pointer
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 915000 gcc-4.5
  Show dependency tree
 
Reported: 2010-08-30 02:58 UTC by Henry Wertz
Modified: 2023-10-01 06:05 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Henry Wertz 2010-08-30 02:58:20 UTC
I just unmasked gcc-4.5.1 and started rebuilding world.   I was build with CFLAGS CFLAGS="-O2 -march=athlon-xp -fomit-frame-pointer -floop-block -floop-interchange -floop-strip-mine"   Mysql compiled and appeared functional, however mythtv failed, apparently due to mysql mishandling requests to lock a table.   On inspection, I found the following failure:
mysql -u mythtv -p mythconverg
password: ***** (OK, it's mythtv haha)
..... (Version 5.1.50)
mysql>  lock table schemalock write;
Access denied for user 'mythtv'@'localhost' to database '?????'
     The "?????" is either empty, or has several bytes of garbage in it.
     (UNLOCK TABLES works fine though!)
     OK I thought my build flags were too agressive.   I "emerge -e mythtv" with CFLAGS of "-O2 -march=athlon-xp -fomit-frame-pointer".   Same failure.  I dropped back to 5.1.49 and same failure.  I rebuilt just mysql with gcc-4.4.4 and it's fine.  I'll add to this post 


Reproducible: Always

Steps to Reproduce:
1. Install gcc-4.51
2. Rebuild mysql with gcc-4.51
3. attempt to lock a table.

Actual Results:  
Access denied for user 'mythtv'@'localhost' to database '?????'

Expected Results:  
Query OK, 0 rows affected (0.00 sec)
     

     I'll attach make.conf.  I just replaced this machine w/ a Athlon64, so that's why I have "march=k8-sse", but I tested with the old "athlon-xp" flags.  k8-sse works too.
Comment 1 Henry Wertz 2010-08-30 03:05:23 UTC
Portage 2.1.8.3 (default/linux/x86/10.0/desktop, gcc-4.5.1, glibc-2.12.1-r1, 2.6.33-gentoo i686)
=================================================================
System uname: Linux-2.6.33-gentoo-i686-AMD_Athlon-tm-_64_Processor_3800+-with-gentoo-2.0.1
Timestamp of tree: Tue, 24 Aug 2010 00:15:01 +0000
distcc 3.1 i686-pc-linux-gnu [enabled]
ccache version 2.4 [enabled]
app-shells/bash:     4.1_p7
dev-java/java-config: 1.3.7-r1, 2.1.11
dev-lang/python:     2.6.5-r3, 3.1.2-r4
dev-util/ccache:     2.4-r8
dev-util/cmake:      2.8.1-r2
sys-apps/baselayout: 2.0.1
sys-apps/openrc:     0.6.2
sys-apps/sandbox:    2.3-r1
sys-devel/autoconf:  2.13, 2.65-r1
sys-devel/automake:  1.4_p6-r1, 1.8.5-r4, 1.9.6-r3, 1.10.3, 1.11.1
sys-devel/binutils:  2.20.1-r1
sys-devel/gcc:       3.3.6-r1, 4.3.5, 4.4.4-r1, 4.5.1
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.10
sys-devel/make:      3.81-r2
virtual/os-headers:  2.6.35
ACCEPT_KEYWORDS="x86 ~x86"
ACCEPT_LICENSE="*"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=k8-sse3 -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/X11/xkb /usr/share/config /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -march=k8-sse3 -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests ccache distcc distlocks fixpackages news parallel-fetch protect-owned sandbox sfperms strict unmerge-logs unmerge-orphans userfetch"
GENTOO_MIRRORS="http://gentoo.mirrors.tds.net/gentoo"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/rtmp/"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://delta/gentoo-portage"
USE="3dnow 3dnowext X a52 aac acl acpi alsa amr amrnb amrwb asf audiofile avahi berkdb bluetooth bonobo branding browserplugin bzip2 cairo cdr cjk cli consolekit cracklib crosscompile crypt css cups curl cxx dbus divx4linux dri dts dv dvb dvd dvdr dvdread emboss encode exif expat fam fame ffmpeg firefox flac foomaticdb fortran gd gdbm gif gimpprint glitz glut gmp gnutls gpm gtk gtk2 gtkhtml hal iconv idn ieee1394 imagemagick insecure-savers ipv6 irmc java jpeg junit kde kqemu latin1 lcms ldap libnotify lua mad matroska mikmod mjpeg mmx mmxext mng modules mozsvg mp3 mp4 mpeg mudflap mysql mythtv nas ncurses nls nptl nptlonly nsplugin nvidia offensive ogg opengl openmp pam pango pcre pdf perl pic plugin png posix ppds pppd pulseaudio python qt3support qt4 readline reflection ruby samba scanner sdl semantic-desktop session slang spell spl sse ssl startup-notification subtitles svg sysfs tcltk tcpd threads threadsafe tiff truetype unicode uniq usb v4l v4l2 vorbis win32codecs wma wmf wmp x264 x86 xanim xcb xine xml xml2 xorg xulrunner xv xvid zeroconf zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIRC_DEVICES="all" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="nvidia nv" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" 
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

-----------------
     Again, note, I did this test with CFLAGS="-O2 -march=athlon-xp -fomit-frame-pointer", but both athlon-xp and k8-sse3 seem to wo
Comment 2 Henry Wertz 2010-08-30 03:57:00 UTC
gcc-4.5.1 does work fine with -O1, i.e. 
CFLGS="-O1 -march=k8-sse3 -fomit-frame-pointer" CXXFLAGS=${CFLAGS} emerge --oneshot mythtv

     results in a working binary.
Comment 3 Henry Wertz 2010-08-30 15:19:01 UTC
(In reply to comment #2)
> gcc-4.5.1 does work fine with -O1, i.e. 
> CFLGS="-O1 -march=k8-sse3 -fomit-frame-pointer" CXXFLAGS=${CFLAGS} emerge
> --oneshot mythtv
> 
>      results in a working binary.
> 

     Oh, I meant --oneshot mysql of course.
Comment 4 SpanKY gentoo-dev 2010-08-31 17:27:51 UTC
and what about -O2 -march=k8 ?  what if you rebuild gcc itself with your simpler CFLAGS and then mysql ?
Comment 5 Henry Wertz 2010-09-01 07:55:17 UTC
     Huh, I hadn't thought of gcc miscompiling itself 8-).  Anyway...with "my" gcc,
I ran
CFLAGS="-O2 -march=k8" CXXFLAGS=${CFLAGS} FEATURES="-distcc -ccache" emerge --oneshot mysql
     and it works.  CFLAGS="-O2 -march=k8-sse3" also works.  "-O2 -march=k8-sse3 -fomit-frame-pointer" breaks it.  I thought -fomit-frame-pointer was considered a safe option, and was just off by default because it gives gdb a hard time.

     With gcc built "-O2 -march=k8", I have the same result -- building mysql with "-O2 -march-k8-sse3 -fomit-frame-pointer" results in errors.

Here's a second bug I found where mysql broke on i686 with -fomit-frame-pointer and worked without it:
http://bugs.mysql.com/bug.php?id=45205

Comment 6 Brian Evans (RETIRED) gentoo-dev 2010-09-09 20:39:03 UTC
See also bug 335995, It seems -fomit-frame-pointer is not safe for MySQL 5.1.* on x86
Comment 7 Tolga Dalman 2010-09-29 21:00:22 UTC
Can anyone confirm ? If so, -fomit-frame-pointer should be disabled to fix this bug then ?
Comment 8 Henry Wertz 2010-10-05 00:13:48 UTC
(In reply to comment #7)
> Can anyone confirm ? If so, -fomit-frame-pointer should be disabled to fix this
> bug then ?
> 

     Well, I'm the OP so I don't know if my statement is confirmation, but removing -fomit-frame-pointer worked for me, it worked in the case of MySQL bug 45205 (which was not even a gentoo system, and I doubt was using gcc-4.5 since it was from July 2009), and it worked for gentoo bug 335995 as well.  I think this flag should be stripped, and perhaps a one-line note to the effect of "-fomit-frame-pionter flag causes problems so this flag is stripped" should be printed in the build output.

     I don't know where to begin looking into it, but I do wonder if this is truly a bug in mysql, as opposed to a subtle compiler error in gcc-4.5 and probably 4.4  (I had trouble with mythtv as well with gcc-4.4 and 4.5, it crashes frequently built with -march=athlon64 or -march=k8-sse3 but it runs fine with -march=athlon-xp.)  Either way though, even if it is a gcc bug until gcc is fixed, IMHO it makes sense to mask this flag since it pretty much effects one package.
Comment 9 Christophe Paccolat 2010-10-06 09:31:27 UTC
Just as a side note: -fomit-frame-pointer will be the default when not optimizing for size with the next release of GCC (http://gcc.gnu.org/gcc-4.6/changes.html). This issue will probably come up again in the future. We might want to create a meta-bug for this since "filter-flags" doesn't force "-fno-omit-frame-pointer"...
Comment 10 Ryan Hill (RETIRED) gentoo-dev 2010-10-07 03:49:54 UTC
a meta-bug for what?  any package breaking with -fomit-frame-pointer will have already been long fixed; everyone and their duck uses it.

I'm pretty sure this is a dupe of bug #335995.
Comment 11 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2010-10-07 05:57:49 UTC
Yup dupe.

Upstream hasn't been helpful at all in finding it.

toolchain:
Can we force "use x86 && append-flags -fno-omit-frame-pointer" in mysql?
Comment 12 Ryan Hill (RETIRED) gentoo-dev 2010-10-11 07:21:40 UTC
Please do.
Comment 13 SpanKY gentoo-dev 2010-10-11 07:52:35 UTC
you must qualify flag workarounds with gcc-version checks and quote the note the exact bug # that this is for.  otherwise that crap tends to stick around forever and no one has a clue wtf it's for.
Comment 14 Ryan Hill (RETIRED) gentoo-dev 2010-10-27 02:56:20 UTC
Can I get you to add the workaround?  This is the only thing blocking 4.5 unmasking.  I'd supply a patch but I have no idea where in the ebuild/eclass you would want to put it.
Comment 15 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2010-10-27 07:19:57 UTC
(In reply to comment #14)
> Can I get you to add the workaround?  This is the only thing blocking 4.5
> unmasking.  I'd supply a patch but I have no idea where in the ebuild/eclass
> you would want to put it.
In eclass now.
Comment 16 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2010-10-28 20:33:06 UTC
*** Bug 335995 has been marked as a duplicate of this bug. ***