Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 151394 - [4.1/bad-code] sys-libs/zlib makes linked apps segfault w/ -ftree-vectorize and glibc-2.5
Summary: [4.1/bad-code] sys-libs/zlib makes linked apps segfault w/ -ftree-vectorize a...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Gentoo Toolchain Maintainers
URL: http://gcc.gnu.org/PR32893
Whiteboard:
Keywords:
: 154013 221981 (view as bug list)
Depends on:
Blocks: 169074
  Show dependency tree
 
Reported: 2006-10-14 15:51 UTC by Jakub Moc (RETIRED)
Modified: 2010-04-16 22:27 UTC (History)
9 users (show)

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


Attachments
gcc-4.2.0-vectorize-pr32893.patch (gcc-4.2.0-vectorize-pr32893.patch,546 bytes, patch)
2007-10-28 14:30 UTC, Ryan Hill (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Moc (RETIRED) gentoo-dev 2006-10-14 15:51:09 UTC
Spent couple of hours on this :X sys-libs/zlib compiled w/ -ftree-vectorize makes mozilla-firefox{-bin}, mozilla-thunderbird{,-bin}, openoffice{-bin} segfault randomly. Recompiling without that flag fixed all the issues.

- mozilla-firefox{-bin} crashes on Help - About Mozilla Firefox or when opening file from menu

- mozilla-thunderbird{,-bin} crashes on Help - About, also when signing emails via enigmail plugin (both compiled from source or installed from mozilla website)

- openoffice{-bin} completely fails to start any application.

- the above plus other GTK2 apps crash randomly when working with fileselector

Weird that this wasn't an issue w/ glibc-2.4, hmmm... Anyway, I'd say filtering the flag would make sense for now.
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2006-10-14 15:52:23 UTC
Portage 2.1.2_pre2-r9 (default-linux/x86/2006.1/desktop, gcc-4.1.1, glibc-2.5-r0, 2.6.18-gentoo i686)
=================================================================
System uname: 2.6.18-gentoo i686 AMD Athlon(tm) XP 1600+
Gentoo Base System version 1.12.5
Last Sync: Sat, 14 Oct 2006 18:00:01 +0000
ccache version 2.4 [enabled]
app-admin/eselect-compiler: [Not Present]
dev-java/java-config: 2.0.30
dev-lang/python:     2.4.3-r4
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     2.4-r6
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.18.1
sys-devel/autoconf:  2.13, 2.60
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.17, 2.17.50.0.3, 2.17.50.0.5
sys-devel/gcc-config: 1.3.13-r4
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.17-r1
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=athlon-xp -O2 -pipe -fomit-frame-pointer -fforce-addr -ftree-vectorize"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/java-config/vms/ /etc/revdep-rebuild /etc/splash /etc/terminfo"
CXXFLAGS="-march=athlon-xp -O2 -pipe -fomit-frame-pointer -fforce-addr -ftree-vectorize"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--alphabetical"
FEATURES="autoconfig ccache collision-protect distlocks metadata-transfer parallel-fetch sandbox sfperms splitdebug strict userfetch userpriv usersandbox"
GENTOO_MIRRORS="ftp://ftp.sh.cvut.cz/MIRRORS/gentoo/gentoo ftp://ftp.fi.muni.cz/pub/linux/gentoo/"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--sort-common"
LINGUAS="cs en"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_EXTRA_OPTS="--progress"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage /usr/local/overlays/beryl"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="x86 3dnow 3dnowext 7zip X X509 a52 aac acl acpi alsa amr asf audiofile bash-completion berkdb bluetooth bzip2 cairo caps cddb cdparanoia cdr chroot cli crypt cscope css cups curl curlwrappers dbus dbx dga dlloader dri dts dv dvd dvdr dvdread elibc_glibc encode ethereal exif expat fam fbcon ffmpeg fftw firefox flac flash flatfile foomaticdb gd gdbm gif glitz glut gmp gpm gstreamer gtk iconv icq idn imagemagick imap imlib inifile input_devices_joystick input_devices_keyboard input_devices_mouse input_devices_vmmouse ipv6 irda jack javascript jbig joystick jpeg jpeg2k kdeenablefinal kdehiddenvisibility kernel_linux lcms libcaca libg++ libsamplerate linguas_cs linguas_en lirc lirc_devices_cph06x lm_sensors logrotate mad maildir matroska mikmod mime mmap mmx mng mp3 mpeg musepack musicbrainz ncurses nls nodrm nptl nptlonly nsplugin nvidia offensive ogg openal opengl pam pcre pdf perl png ppds python qt3 quicktime readline real reflection samba sdl session sftplogging skey sndfile speex spell spl sse ssl startup-notification svg symlink tcpd theora threads tiff truetype udev unicode urandom usb userland_GNU v4l v4l2 vcd video_cards_fbdev video_cards_nv video_cards_nvidia video_cards_v4l video_cards_vesa video_cards_vmware vorbis win32codecs wmf x264 xcomposite xine xinerama xinetd xml xml2 xmlrpc xorg xosd xpm xv xvid xvmc zlib"
Unset:  CTARGET, INSTALL_MASK, LC_ALL
Comment 2 Jakub Moc (RETIRED) gentoo-dev 2006-10-14 15:54:22 UTC
A sample backtrace from running mozilla-thunderbird:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1223895360 (LWP 2128)]
0xb7299076 in inflate_table () from /lib/libz.so.1
(gdb) bt
#0  0xb7299076 in inflate_table () from /lib/libz.so.1
#1  0x00000001 in ?? ()
#2  0x0000021e in ?? ()
#3  0x08d39430 in ?? ()
#4  0xb797e5b8 in g__g_dataset_global_lock () from /usr/lib/libglib-2.0.so.0
#5  0x0a3d3f30 in ?? ()
#6  0xb7990f89 in g_object_dispatch_properties_changed () from /usr/lib/libgobject-2.0.so.0
#7  0xb7920380 in g_free () from /usr/lib/libglib-2.0.so.0
#8  0x095b4e00 in ?? ()
#9  0xb79bc6f0 in ?? () from /usr/lib/libgobject-2.0.so.0
#10 0x08d39430 in ?? ()
#11 0xb79924a0 in g_object_newv () from /usr/lib/libgobject-2.0.so.0
#12 0xbff1a5c4 in ?? ()
Comment 3 SpanKY gentoo-dev 2006-10-14 22:55:07 UTC
no, we arent going to filter flags

your backtrace is useless

try emerging zlib with those ricer flags and FEATURES=test
Comment 4 Jakub Moc (RETIRED) gentoo-dev 2006-10-15 00:26:45 UTC
<snip>
>>> Test phase [check]: sys-libs/zlib-1.2.3-r1
hello world
zlib version 1.2.3 = 0x1230, compile flags = 0x55
uncompress(): hello, hello!
gzread(): hello, hello!
gzgets() after gzseek:  hello!
inflate(): hello, hello!
large_inflate(): OK
after inflateSync(): hello, hello!
inflate with dictionary: hello, hello!
		*** zlib test OK ***
</snip>

And, all those apps crash again like mad. So, the test is not much useful.
Comment 5 Pacho Ramos gentoo-dev 2006-10-17 11:03:26 UTC
Have you tried to re-emerge zlib without -fomit-frame-pointer CFLAG

Good luck!
Comment 6 Jakub Moc (RETIRED) gentoo-dev 2006-10-17 12:39:09 UTC
(In reply to comment #5)
> Have you tried to re-emerge zlib without -fomit-frame-pointer CFLAG

Works just fine when -ftree-vectorize is removed, -fomit-frame-pointer has no influence.
Comment 7 Pacho Ramos gentoo-dev 2006-10-17 14:17:55 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > Have you tried to re-emerge zlib without -fomit-frame-pointer CFLAG
> 
> Works just fine when -ftree-vectorize is removed, -fomit-frame-pointer has no
> influence.
> 

Thanks a lot for information :-)

Then, Could be -ftree-vectorize be filtered by zlib ebuild?

Thanks a lot :-)
Comment 8 SpanKY gentoo-dev 2006-10-17 14:39:21 UTC
read comment #3 again
Comment 9 Ryan Hill (RETIRED) gentoo-dev 2006-10-21 15:37:07 UTC
fails with vanilla 4.1 and 4.2 branch svn.
Comment 10 Jakub Moc (RETIRED) gentoo-dev 2006-11-04 04:07:50 UTC
*** Bug 154013 has been marked as a duplicate of this bug. ***
Comment 11 Jory A. Pratt 2006-11-11 15:49:57 UTC
(In reply to comment #3)
> no, we arent going to filter flags
> 
> your backtrace is useless
> 
> try emerging zlib with those ricer flags and FEATURES=test
> 

I agree with spanky I have the entire system with compiled way I want it now and do not have any problems.

Portage 2.1.2_rc1-r5 (default-linux/amd64/2006.1, gcc-4.1.1, glibc-2.5-r0, 2.6.18-ck1-r1 x86_64)
=================================================================
System uname: 2.6.18-ck1-r1 x86_64 AMD Sempron(tm) Processor 3200+
Gentoo Base System version 1.12.6
Last Sync: Sat, 11 Nov 2006 19:30:02 +0000
ccache version 2.4 [enabled]
dev-lang/python:     2.4.4
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     2.4-r6
sys-apps/sandbox:    1.2.18.1
sys-devel/autoconf:  2.13, 2.60
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.17
sys-devel/gcc-config: 1.3.14
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.17-r1
ACCEPT_KEYWORDS="amd64 ~amd64"
AUTOCLEAN="yes"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -march=athlon64 -ffast-math -ftracer -fprefetch-loop-arrays -pipe -fforce-addr -ftree-vectorize"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/X11/xkb"
CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-O2 -march=athlon64 -ffast-math -ftracer -fprefetch-loop-arrays -pipe -fforce-addr -ftree-vectorize"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs autoconfig candy ccache cvs distlocks metadata-transfer sandbox sfperms strict userpriv usersandbox"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/home/gentoo"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="amd64 X acpi alsa audacious berkdb bitmap-fonts bzip2 crypt dbus dlloader dri dvd dvdread elibc_glibc firefox gif gnome gtk gtk+ hal input_devices_keyboard input_devices_mouse input_devices_synaptics ipv6 jpeg kernel_linux libg++ mp3 ncurses no-old-linux nptl nptlonly objc objc++ opengl pam pcre perl pic png python readline session ssl svg tcpd tiff truetype-fonts type1-fonts udev unicode userland_GNU video_cards_fglrx xinerama xorg zlib"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, MAKEOPTS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 12 Jory A. Pratt 2006-11-12 07:10:16 UTC
Well I have test on my x86 last night and was able to duplicate the problem. As far as I can see this is only effecting x86 arch.

Portage 2.1.2_rc1-r5 (default-linux/x86/2006.1, gcc-4.1.1, glibc-2.5-r0, 2.6.18-ck1-r1 i686)
=================================================================
System uname: 2.6.18-ck1-r1 i686 AMD Athlon(tm) XP 2200+
Gentoo Base System version 1.12.6
Last Sync: Sat, 11 Nov 2006 19:00:01 +0000
ccache version 2.4 [enabled]
dev-lang/python:     2.4.4
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     2.4-r6
sys-apps/sandbox:    1.2.18.1
sys-devel/autoconf:  2.13, 2.60
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.17
sys-devel/gcc-config: 1.3.14
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.17-r1
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=athlon-xp -ffast-math -ftracer -fprefetch-loop-arrays -pipe -fforce-addr -ftree-vectorize"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/X11/xkb"
CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/terminfo"
CXXFLAGS="-O2 -march=athlon-xp -ffast-math -ftracer -fprefetch-loop-arrays -pipe -fforce-addr -ftree-vectorize"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs autoconfig candy ccache cvs distlocks metadata-transfer sandbox sfperms strict userpriv usersandbox"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/home/gentoo"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="x86 X acpi alsa audacious berkdb bitmap-fonts bzip2 crypt dbus dlloader dri dvd dvdr dvdread elibc_glibc firefox gif gnome gtk gtk+ hal input_devices_keyboard input_devices_mouse ipv6 jpeg kernel_linux libg++ mp3 ncurses no-old-linux nptl nptlonly objc objc++ opengl pam pcre perl pic png python readline session ssl svg tcpd tiff truetype-fonts type1-fonts udev unicode userland_GNU video_cards_nvidia win32codecs xinerama xorg zlib"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, MAKEOPTS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 13 Christophe Saout 2006-12-03 09:58:25 UTC
Well, I just looked into this, and the problem is more subtle.

It's not a gcc bug, it's a stack alignment issue. By default, the newer gcc keeps the stack aligned to a 16-byte boundary. -ftree-vectorize silently assumes that the functions are called with the correct alignment. If such a function that uses SSE2 is called with an stack pointer that can't be divided by 16, the "movdqa" instruction will segfault (the 'a' in movdqa stands for aligned and is faster than movdqu, but only works if the memory access is aligned).

In my case, firefox calls down with an unaligned stack pointer into libpng, which calls down into zlib (inflate), which then crashes.

I don't know what's going on in these applications to get an unaligned stack.
Comment 14 Daniel Mario Vega 2006-12-07 21:41:31 UTC
rpm tools also fails if zlib build with -ftree-vectorize 
Comment 15 Stefan Briesenick (RETIRED) gentoo-dev 2006-12-21 02:13:03 UTC
I can confirm this behavior. I have this problem since GCC 4.x went into portage (when I started to use it). Don't know if there's a difference between glibc-2.4/2.5.

All I can say is: many GTK apps are randomly crashing with zlib compiled with -ftree-vectorize. As soon as you recompile zlib w/o that switch, all problems are gone. And yes, I already re-emerged my whole system.

If there's no other solution, I vote for filtering that switch in zlib!
Comment 16 Christophe Saout 2006-12-21 02:32:58 UTC
No, filtering would be stupid. In theory the problem can happen with any library that contains SSE instructions and are called with an unaligned stack. Unfortunately the libraries cannot control the stack alignment (except for an expensive gcc parameter that explicitly aligns the stack in the function prologue), so -ftree-vectorize shouldn't be used for any packages that install libraries.
Comment 17 SpanKY gentoo-dev 2006-12-21 06:20:40 UTC
could you possibly rip out a small bit of code from zlib that still exhibits this behavior ?
Comment 18 Stefan Briesenick (RETIRED) gentoo-dev 2006-12-21 13:26:56 UTC
The problem is, that SSE-Code can be everywhere, whether compiled with -ftree-vectorize or not. GCC should produce SIMD code which is immune against misaligned data. So it's a GCC bug? Or is it a zlib bug?

nontheless, -ftree-vectorize is a great and good option. I don't want to see it filtered in general. And zlib is the only lib I've seen till now, which shows this behaviour.

My whole system is compiled with -ftree-vectorize and it's rock-solid, as long zlib is compiled w/o -ftree-vectorize.
Comment 19 SpanKY gentoo-dev 2006-12-21 23:47:34 UTC
if you throw gdb at it and you see that it breaks in 1 function, you can backtrace the buffers it is utilizing

as Christophe said, we're not going to filter in zlib
Comment 20 Daniel Mario Vega 2006-12-28 20:15:08 UTC
The following example was created using rpm2cpio and zlib compiled with -ftree-vectorize

daniel@fierita /tmp $ gdb /usr/bin/rpm2cpio
GNU gdb 6.4
Copyright 2005 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-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".

gdb> set args /tmp/libutempter-1.1.4-alt1.src.rpm
gdb> dir /var/tmp/portage/rpm-4.4.6-r3/work/rpm-4.4.6/rpmio
gdb> dir /var/tmp/portage/zlib-1.2.3-r1/work/zlib-1.2.3
gdb> run
[Thread debugging using libthread_db enabled]
[New Thread -1480620368 (LWP 12509)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1480620368 (LWP 12509)]
Error while running hook_stop:
Invalid type combination in ordering comparison.
inflate_table (type=CODES, lens=0x80576c8, codes=0x13, table=0x80576c4, bits=0x80576ac, work=0x8057948) at inftrees.c:108
108             count[len] = 0;
gdb> bt
#0  inflate_table (type=CODES, lens=0x80576c8, codes=0x13, table=0x80576c4, bits=0x80576ac, work=0x8057948) at inftrees.c:108
#1  0xa7d21156 in inflate (strm=0x8052b88, flush=0x0) at inflate.c:866
#2  0xa7d1ad59 in gzread (file=0x8052b88, buf=0xa7bf6000, len=0x2000) at gzio.c:464
#3  0xa7d9fd6d in gzdRead (cookie=0x8051018, buf=0xa7bf6000 "", count=0x2000) at rpmio.c:2227
#4  0xa7c4e511 in _IO_cookie_read (fp=0x13, buf=0xa7bf6000, size=0x2000) at iofopncook.c:55
#5  0xa7c5982a in _IO_new_file_underflow (fp=0x8052d68) at fileops.c:593
#6  0xa7c5b3bd in *__GI___underflow (fp=0x8052d68) at genops.c:356
#7  0xa7c5b4fd in _IO_default_xsgetn (fp=0x8052d68, data=0xafe23c8c, n=0x2000) at genops.c:535
#8  0xa7c59f98 in _IO_sgetn (fp=0x8052d68, data=0xafe23c8c, n=0x2000) at genops.c:495
#9  0xa7c4e9e0 in _IO_fread (buf=0xafe23c8c, size=0x1, count=0x2000, fp=0x8052d68) at iofread.c:44
#10 0xa7d9cec4 in Fread (buf=0xafe23c8c, size=0x1, nmemb=0x2000, fd=0x8051018) at rpmio.c:2616
#11 0xa7d9cf75 in ufdCopy (sfd=0x8051018, tfd=0x8051248) at rpmio.c:1350
#12 0x0804bb61 in main (argc=Cannot access memory at address 0x13
) at rpm2cpio.c:86
gdb> list *$pc
0xa7d23d2d is in inflate_table (inftrees.c:108).
103            decoding tables.
104          */
105
106         /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
107         for (len = 0; len <= MAXBITS; len++)
108             count[len] = 0;
109         for (sym = 0; sym < codes; sym++)
110             count[lens[sym]]++;
111
112         /* bound code lengths, force root to be within code lengths */
gdb> disass
Dump of assembler code for function inflate_table:
0xa7d23d10 <inflate_table+0>:   push   %ebp
0xa7d23d11 <inflate_table+1>:   xorps  %xmm0,%xmm0
0xa7d23d14 <inflate_table+4>:   mov    %esp,%ebp
0xa7d23d16 <inflate_table+6>:   push   %edi
0xa7d23d17 <inflate_table+7>:   push   %esi
0xa7d23d18 <inflate_table+8>:   push   %ebx
0xa7d23d19 <inflate_table+9>:   call   0xa7d19557 <__i686.get_pc_thunk.bx>
0xa7d23d1e <inflate_table+14>:  add    $0x5e92,%ebx
0xa7d23d24 <inflate_table+20>:  sub    $0xcc,%esp
0xa7d23d2a <inflate_table+26>:  mov    0x10(%ebp),%esi
0xa7d23d2d <inflate_table+29>:  movaps %xmm0,0xffffffc8(%ebp)
0xa7d23d31 <inflate_table+33>:  movaps %xmm0,0xffffffd8(%ebp)
0xa7d23d35 <inflate_table+37>:  test   %esi,%esi
0xa7d23d37 <inflate_table+39>:  je     0xa7d23d51 <inflate_table+65>
0xa7d23d39 <inflate_table+41>:  xor    %edx,%edx
0xa7d23d3b <inflate_table+43>:  nop
0xa7d23d3c <inflate_table+44>:  lea    0x0(%esi),%esi
0xa7d23d40 <inflate_table+48>:  mov    0xc(%ebp),%ecx
0xa7d23d43 <inflate_table+51>:  movzwl (%ecx,%edx,2),%eax
0xa7d23d47 <inflate_table+55>:  inc    %edx
0xa7d23d48 <inflate_table+56>:  incw   0xffffffc8(%ebp,%eax,2)
0xa7d23d4d <inflate_table+61>:  cmp    %edx,%esi
0xa7d23d4f <inflate_table+63>:  jne    0xa7d23d40 <inflate_table+48>
End of assembler dump.
gdb> info registers
eax            0x80576c8        0x80576c8
ecx            0x13     0x13
edx            0x8057658        0x8057658
ebx            0xa7d29bb0       0xa7d29bb0
esp            0xafe238a8       0xafe238a8
ebp            0xafe23980       0xafe23980
esi            0x13     0x13
edi            0x8052b88        0x8052b88
eip            0xa7d23d2d       0xa7d23d2d <inflate_table+29>
eflags         0x210292 0x210292
cs             0x73     0x73
ss             0x7b     0x7b
ds             0x7b     0x7b
es             0x7b     0x7b
fs             0x0      0x0
gs             0x33     0x33
gdb>
Comment 21 Ryan Hill (RETIRED) gentoo-dev 2007-06-22 23:29:55 UTC
this is GCC PR 25413.  i brought it up on the gcc-dev ml, and dorit said he would try to clean up a previously submitted patch (available @ http://gcc.gnu.org/ml/gcc-patches/2006-03/msg00167.html) and get it committed.


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25413
Comment 22 Ryan Hill (RETIRED) gentoo-dev 2007-07-25 21:46:52 UTC
this is now PR32893.

http://gcc.gnu.org/PR32893
Comment 23 Ryan Hill (RETIRED) gentoo-dev 2007-10-28 14:30:22 UTC
Created attachment 134533 [details, diff]
gcc-4.2.0-vectorize-pr32893.patch

this is part of a bigger issue with stack alignment in GCC (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33721), which will be addressed in 4.4.  in the meantime, this workaround has been working for me for several months now.  it also prevents bug #135632 and bug #196555.

http://comments.gmane.org/gmane.comp.gcc.patches/150943
Comment 24 Christophe Saout 2007-10-28 18:40:53 UTC
Is this patch going into the Gentoo gcc patchset? If I understand correctly, it only affects the vectorizer. And some suboptimal auto-vectorizing is still better then no auto-vectorizing at all, right?

I'm asking since I've forward-ported the patchset to gcc 4.3.0 (except for some non-x86 architectures I was too lazy to fix the clashes for) and wanted to start experimenting with that one as my default compiler. I noticed that the issue was still there, which is getting kind of upsetting.
Comment 25 Ryan Hill (RETIRED) gentoo-dev 2007-10-28 19:41:58 UTC
i would not recommend this going into the gentoo patchset until it gets merged upstream.  there is already talk of adding another STACK_BOUNDARY macro.

so consider it an FYI WFM. ;)
Comment 26 Ryan Hill (RETIRED) gentoo-dev 2007-10-31 00:02:30 UTC
this has gone in upstream.

http://gcc.gnu.org/viewcvs/trunk/gcc/tree-vectorizer.c?r1=128289&r2=129764&pathrev=129764
Comment 27 Ryan Hill (RETIRED) gentoo-dev 2007-10-31 00:07:22 UTC
the full patch is at http://gcc.gnu.org/ml/gcc-patches/2007-10/msg01785.html
Comment 28 SpanKY gentoo-dev 2008-06-12 13:40:10 UTC
*** Bug 221981 has been marked as a duplicate of this bug. ***
Comment 29 Mark Loeser (RETIRED) gentoo-dev 2009-04-20 00:58:55 UTC
gcc-4.3 is now stable
Comment 30 Johannes Hirte 2010-04-16 21:40:13 UTC
This bug is still present for me with gcc-4.4.3. When -ftree-vectorize is set for sys-libs/zlib, firefox and firefox-bin are crashing on startup. Additional the adobe-flash plugin is triggering this in dev-libs/libgcrypt and media-libs/fontconfig. When -ftree-vectorize is set for this packages, the plugin is crashing on youtube and taking firefox with it. After removing -ftree-vectorize from CFLAGS for this three packages, everything works fine so far.

emerge --info

Portage 2.2_rc67 (default/linux/x86/10.0, gcc-4.4.3, glibc-2.11-r1, 2.6.34-rc4 i686)
=================================================================
System uname: Linux-2.6.34-rc4-i686-Intel-R-_Atom-TM-_CPU_N270_@_1.60GHz-with-gentoo-2.0.1
Timestamp of tree: Fri, 16 Apr 2010 09:30:01 +0000
distcc 3.1 i686-pc-linux-gnu [disabled]
app-shells/bash:     4.1_p5
dev-java/java-config: 2.1.10
dev-lang/python:     2.6.5-r1, 3.1.2-r2
dev-util/cmake:      2.8.1-r1
sys-apps/baselayout: 2.0.1
sys-apps/openrc:     0.6.1-r1
sys-apps/sandbox:    2.2
sys-devel/autoconf:  2.13, 2.65
sys-devel/automake:  1.9.6-r3, 1.10.3, 1.11.1
sys-devel/binutils:  2.20.1
sys-devel/gcc:       4.3.4, 4.4.3
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.6b
virtual/os-headers:  2.6.33
ACCEPT_KEYWORDS="x86 ~x86"
ACCEPT_LICENSE="* -@EULA dlj-1.1"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=core2 -m32 --param l1-cache-line-size=64 --param l1-cache-size=32 --param l2-cache-size=512 -mssse3 -mfpmath=sse -fweb -funswitch-loops -fpredictive-commoning -fgcse-after-reload -ftree-vectorize -fomit-frame-pointer -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /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=core2 -m32 --param l1-cache-line-size=64 --param l1-cache-size=32 --param l2-cache-size=512 -mssse3 -mfpmath=sse -fweb -funswitch-loops -fpredictive-commoning -fgcse-after-reload -ftree-vectorize -fomit-frame-pointer -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--with-bdeps=y"
FEATURES="assume-digests distlocks fixpackages news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unmerge-logs unmerge-orphans userfetch"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="C"
LDFLAGS="-Wl,-O1"
LINGUAS="de"
MAKEOPTS="-j2"
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/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage/layman/toolchain /usr/local/portage/layman/x11 /usr/local/portage/layman/kde /usr/local/portage/layman/java-overlay /usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X aac acl acpi addressbook aio akonadi alsa aspell ayatana bash-completion berkdb bzip2 cairo caps cdda cddb cdparanoia chm cleartype cli consolekit contrast cracklib crypt cups cvs cxx dbus dirac djvu dri eap-tls exif expat faac faad ffmpeg fftw flac fortran gdbm geolocation gif gimp git glibc-omitfp glitz gmp gpm graphite graphviz gs hal hotpixels iconv imagemagick inotify ipv6 java java6 jpeg kde kipi kpathsea lcms ldap lensfun libffi lm_sensors lto lzma lzo md5sum mmap mmx mng modules mp3 mpi mpi-threads mplayer mudflap musicbrainz mysql ncurses networkmanager nls npp nptl nptlonly nsplugin ntp ogg openal opencore-amr openexr opengl openmp optimized-qmake oscar otr pam pcre pdf perl plasma png pnm policykit pppd python python3 qt qt3support qt4 raster raw readline reflection samba schroedinger sdl semantic-desktop session smp sndfile speex spell spl sqlite sqlite3 sse sse2 ssl ssse3 subversion svg sysfs system-sqlite tcpd theora threads thumbnail tiff timezone truetype unicode usb v4l v4l2 vim-syntax vorbis wavpack wmf wps x264 x86 xattr xcb xcomposite xml xmp xorg xpm xscreensaver xv xvid zip 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 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="evdev synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="de" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="intel" 
Unset:  CPPFLAGS, CTARGET, FFLAGS, INSTALL_MASK, LC_ALL, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 31 SpanKY gentoo-dev 2010-04-16 22:27:54 UTC
there are multiple bugs related to the underlying issue in different versions of gcc.  short answer: dont use stack packing flags on x86 systems because the ABI is so f-ed up wrt stack alignment.  we arent going to waste time on this topic as is isnt a bug in packages, and the gcc behavior isnt entirely wrong.