Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 228287 - app-arch/lzma-utils-4.32.[5|6|7] regression from gcc-4.1 to 4.2/4.3
Summary: app-arch/lzma-utils-4.32.[5|6|7] regression from gcc-4.1 to 4.2/4.3
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: HPPA Linux
: High normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL: http://thread.gmane.org/gmane.linux.p...
Whiteboard:
Keywords:
Depends on:
Blocks: 243342 256430
  Show dependency tree
 
Reported: 2008-06-19 06:44 UTC by Luca Lesinigo
Modified: 2009-12-27 17:01 UTC (History)
3 users (show)

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


Attachments
lzma-utils-4.32.6-workdir-O0-O1.diff (lzma-utils-4.32.6-workdir-O0-O1.diff,120.40 KB, text/plain)
2008-06-23 19:56 UTC, Jeroen Roovers (RETIRED)
Details
gdb backtrace (gdb.log,4.51 KB, text/plain)
2008-06-30 21:58 UTC, Jeroen Roovers (RETIRED)
Details
GCC delayed branching fix for march=2.0 (gcc-delayed-branching-pa2.0.patch,572 bytes, patch)
2009-01-04 23:32 UTC, Guy Martin (RETIRED)
Details | Diff
GCC delayed branching fix for march=2.0 (gcc-delayed-branching-pa2.0.patch,582 bytes, patch)
2009-01-05 19:44 UTC, Guy Martin (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Luca Lesinigo 2008-06-19 06:44:42 UTC
app-arch/lzma-utils-4.32.5 and 4.32.6 will compile fine but segfault when decompressing stuff on HPPA if both -O[1|2|3] and -march=2.0 are in CXXFLAGS and C++ parts are used. it was fine in gcc-4.1

It will always work fine if:
* -O0 is used, regardless of -march
* -march=1.1 is used, regardless of -O
* -march is omitted, regardless of -O
* USE=nocxx is used, regardless of CFLAGS

ie., CFLAGS=CXXFLAGS='-O2 -march=2.0' will decompress stuff fine if USE=nocxx
CFLAGS='-O2 -march=2.0' and CXXFLAGS='-O2 -march=1.1' will decompress stuff fine if USE=-nocxx

FEATURES="test" will catch the problem with 2 of 2 tests failed.

This problem is confirmed with:
* gcc-4.3.1, glibc-2.8_p20080602, 64bit SMP kernel
* gcc-4.2.4, glibc-2.7-r2, 64bit SMP kernel
* gcc-4.2.4, glibc-2.7-r2, 32bit UP kernel
This problem does NOT affect:
* gcc-4.1.2, glibc-2.7-r2, 32bit UP kernel
Comment 1 SpanKY gentoo-dev 2008-06-21 04:31:31 UTC
more likely a compiler bug ... g'luck tracking it down ...
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2008-06-23 19:14:58 UTC
The test segfaults occur irrespective of whether I use gcc-4.2.4 or gcc-4.1.2.
Comment 3 Jeroen Roovers (RETIRED) gentoo-dev 2008-06-23 19:21:58 UTC
Using
  CFLAGS="-O1 -pipe -mschedule=8000 -march=2.0 -g -ggdb -Wall"
instead of 
  CFLAGS="-O2 -pipe -mschedule=8000 -march=2.0 -g -ggdb -Wall"
does not fix the test suite segfaults (using gcc-4.2.4).
Comment 4 Jeroen Roovers (RETIRED) gentoo-dev 2008-06-23 19:56:36 UTC
Created attachment 158149 [details]
lzma-utils-4.32.6-workdir-O0-O1.diff
Comment 5 Jeroen Roovers (RETIRED) gentoo-dev 2008-06-23 19:58:43 UTC
Using
  CFLAGS="-O0 -pipe -mschedule=8000 -march=2.0 -g -ggdb -Wall"
the test suite finishes with no errors. Btw, on all occasions CXXFLAGS="${CFLAGS}" was set.
Comment 6 Jeroen Roovers (RETIRED) gentoo-dev 2008-06-23 19:59:36 UTC
Portage 2.2_rc1 (default-linux/hppa/2007.0, gcc-4.2.4, glibc-2.7-r2, 2.6.25-gentoo-r5-JeR parisc)
=================================================================
System uname: Linux-2.6.25-gentoo-r5-JeR-parisc-PA8700_-PCX-W2-with-glibc2.2
Timestamp of tree: Mon, 23 Jun 2008 16:20:01 +0000
distcc 2.18.3 hppa2.0-unknown-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]
ccache version 2.4 [disabled]
app-shells/bash:     3.2_p33
dev-lang/python:     2.5.2-r4
dev-python/pycrypto: 2.0.1-r6
dev-util/ccache:     2.4-r7
sys-apps/baselayout: 2.0.0
sys-apps/openrc:     0.2.5
sys-apps/sandbox:    1.2.18.1-r2
sys-devel/autoconf:  2.13, 2.61-r2
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.1
sys-devel/binutils:  2.18-r1
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   1.5.26
virtual/os-headers:  2.6.23-r3
ACCEPT_KEYWORDS="hppa"
CBUILD="hppa2.0-unknown-linux-gnu"
CFLAGS="-O2 -pipe -mschedule=8000 -march=2.0 -g -ggdb -Wall"
CHOST="hppa2.0-unknown-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 /var/bind /var/spool/torque /var/www/localhost/htdocs/wordpress/wp-config.php"
CONFIG_PROTECT_MASK="/etc/env.d /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/terminfo /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-O2 -pipe -mschedule=8000 -march=2.0 -g -ggdb -Wall"
DISTDIR="/keeps/gentoo/distfiles"
FEATURES="autoaddcvs buildpkg cvs distlocks fixpackages notitles parallel-fetch preserve-libs sandbox sfperms splitdebug strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://ftp.snt.utwente.nl/pub/os/linux/gentoo http://mirror.muntinternet.net/pub/gentoo/ http://gentoo.tiscali.nl/"
LC_ALL="en_US.UTF-8"
LDFLAGS=""
LINGUAS="en nl he"
MAKEOPTS="-j4"
PKGDIR="/keeps/gentoo/packages/elmer"
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="/mnt/alt/portage-tmp"
PORTDIR="/keeps/gentoo/portage"
PORTDIR_OVERLAY="/keeps/gentoo/local"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="7zip X Xaw3d a52 aac aalib accessibility ads agg alsa amr amrnb amrwb ao aoss apache2 ares arts asf async asyncns audiofile audit automount avfs bash-completion berkdb bidi bittorrent bl bluetooth bzip2 c++ cairo caps catalogs cblas cdb cddb cdparanoia cdr chardet cjk cli cpudetection cracklib crypt cups curl custom-cflags dbtool dbus device-mapper dga dia directfb djbfft domainkeys dts dv dvd dvdr dvdread dxr3 edl elf emacs enca encode esd examples exif expat fam fame fastbuild fastcgi fbcon ffmpeg filter flac fontconfig foomaticdb fortran ftp gadu galago gd gdbm geoip ggi gif gimp gimpprint glep glib glut gmp gnome gnutls gphoto2 gpm gs gsl gtk gtk2 gtkhtml hal hesiod hppa ical icecast iconv idea idn imagemagick imlib immqt-bc inquisitio ipv6 isdnlog ithreads jack javascript jingle jpeg jpeg2k kde kerberos lapack lcms ldap leim libcaca libnotify libsamplerate libwww live logrotate logwatch lua lzo mad matroska memcache metis mhash midi mikmod mmap mng modplug motif mozbranding mp3 mplayer mssql mudflap musepack mysql nas ncurses netpbm network-cron nfconntrack nfs nls nntp nptl nptlonly nsplugin offensive ogg openexr opengl openmp oss ots overlays pam pango pbs pcre pdf pdo-external perl php pic plotutils plugins png portage portaudio postgres povray ppds pppd pulseaudio python pyzord qdbm qt3 qt3support quotas raw readline recode reflection rpc rrdtool rtc ruby samba sasl scanner scim sdl seamonkey server session sid slang slp sms sndfile snmp soundex speex spell spl sqlite ssl startup-notification subversion suhosin supernodal svg swat sysfs syslog talkfilters tcl tcpd test tga theora threads thunar-vfs tidy tiff timidity tk tools truetype twolame udev unicode unzip urandom usb userlocales utempter utf v4l v4l2 vanim vcd vidix vim-syntax vorbis wavpack webdav webinstall winbind wlan wma wmf xanim xchattext xcomposite xface xml xml2 xmpi xorg xpm xrandr xscreensaver xsettings xulrunner xv xvid xvmc zip zip-external zlib" ALSA_CARDS="ad1889 usb-audio" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd 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 dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif so speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev joystick" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en nl he" USERLAND="GNU" VIDEO_CARDS="stifb fbdev matrox"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 7 SpanKY gentoo-dev 2008-06-23 21:54:36 UTC
diff the build files probably wont find you anything useful

try rebuilding individual objects with -O0 vs -O1 and see if you can narrow it down that way
Comment 8 Jeroen Roovers (RETIRED) gentoo-dev 2008-06-24 02:40:54 UTC
app-arch/lzma-utils-4.32.6/work/lzma-4.32.6/src/lzma $ ./lzma -cf < in | wc -c
13
app-arch/lzma-utils-4.32.6/work/lzma-4.32.6/src/lzma $ lzma -cf < in | wc -c
27
app-arch/lzma-utils-4.32.6/work/lzma-4.32.6/src/lzma $ ./lzma -cf < in > out
Segmentation fault
app-arch/lzma-utils-4.32.6/work/lzma-4.32.6/src/lzma $ lzma -cf < in > out
app-arch/lzma-utils-4.32.6/work/lzma-4.32.6/src/lzma $ wc -c in out
38 in
27 out
65 total
Comment 9 Jeroen Roovers (RETIRED) gentoo-dev 2008-06-30 21:58:20 UTC
Created attachment 159025 [details]
gdb backtrace
Comment 10 Luca Lesinigo 2008-09-08 11:54:47 UTC
app-arch/lzma-utils-4.32.7 is affected too. Nothing new if this really is a compiler problem.

For the record, tested with:
* gcc-4.2.4
* glibc-2.7-r2
* CFLAGS=CXXFLAGS="-pipe -O2 -march=2.0"

as before, USE=nocxx works around the problem.
Comment 11 Jeroen Roovers (RETIRED) gentoo-dev 2008-11-07 06:42:51 UTC
sys-devel/gcc-4.3.2 does not fix this issue.
Comment 12 Jeroen Roovers (RETIRED) gentoo-dev 2008-11-10 03:22:48 UTC
Maybe it's a good idea to go out and discover more code that triggers this behaviour. As of now, only lzma-utils does this, and it does it with some really flaky code that seems to have been borrowed out of a Visual C++ manual. I guess we had better mask IUSE=nocxx and be done with it.
Comment 13 Luca Lesinigo 2008-11-14 16:35:47 UTC
(In reply to comment #12)
> Maybe it's a good idea to go out and discover more code that triggers this
> behaviour. As of now, only lzma-utils does this
mysql segfaults with similar conditions: bug #243342

Comment 14 Guy Martin (RETIRED) gentoo-dev 2008-12-31 22:13:10 UTC
It seems that the optimization breaking everything is -fdelayed-branch.

Adding -fno-delayed-branch to CXXFLAGS workaround the issue.
Comment 15 SpanKY gentoo-dev 2008-12-31 22:57:27 UTC
hmm, that sort implies real bad things for parisc gcc ...

has anyone narrowed down the offending object file ?
Comment 16 Guy Martin (RETIRED) gentoo-dev 2008-12-31 23:15:56 UTC
It's src/sdk/7zip/Compress/LZMA/LZMAEncoder.o

I tried to compare the asm output with and without that optimization but it doesn't seem to be the right approach.

It seems to be caused by multiple inheritance etc but nothing sure.
Unfortunately, my C++ skillz are not good enough to produce a test case :-/

Happy new year btw :)

Comment 17 SpanKY gentoo-dev 2009-01-03 10:45:45 UTC
i can build all of LZMADecoder.cpp with -march=2.0 except for the function CDecoder::SetDecoderProperties2 ...
Comment 18 Guy Martin (RETIRED) gentoo-dev 2009-01-04 23:32:17 UTC
Created attachment 177422 [details, diff]
GCC delayed branching fix for march=2.0

Attached the gcc fix.

SpanKY let me know if you want a separate bug for gcc but please commit this ASAP :)
Comment 19 Guy Martin (RETIRED) gentoo-dev 2009-01-04 23:33:56 UTC
Mhh or not. We should probably wait for the official fix.
Comment 20 Guy Martin (RETIRED) gentoo-dev 2009-01-05 19:44:02 UTC
Created attachment 177502 [details, diff]
GCC delayed branching fix for march=2.0

Here is the updated patch from JDA.
Comment 21 Guy Martin (RETIRED) gentoo-dev 2009-01-09 09:59:57 UTC
The attached patch has been commited upstream :
http://gcc.gnu.org/viewcvs/trunk/gcc/config/pa/pa.c?r1=142147&r2=143113&diff_format=h

@toolchain, can you get that in our tree ? 4.2.4 has been tested quite well and it's the only known regression. It would be nice to have it there.
Also, I think it would be a good idea to patch kgcc64 as well.

Thanks.
Comment 23 Luca Lesinigo 2009-01-21 09:30:54 UTC
sys-devel/gcc-4.2.4-r1 installed and working on my HPPA2.0
using that compiler, lzma-utils-4.32.7 emerged and runs fine on the system while using:
FEATURES=test
USE=-nocxx
CFLAGS=CXXFLAGS="-O2 -pipe -march=2.0"

thanks for solving the issue. Will test mysql later, if it's ok this was the last gcc-4.2.x issue I had on my system. I'll also test building a 32bit kernel.