Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 146300 - sys-devel/gcc-3.4.6-r1 hardened segfaults for std::unique (was: app-portage/eix-0.7.2 gets SEGV when compiled with hardened-gcc)
Summary: sys-devel/gcc-3.4.6-r1 hardened segfaults for std::unique (was: app-portage/e...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: x86 Linux
: High critical (vote)
Assignee: The Gentoo Linux Hardened Team
URL:
Whiteboard:
Keywords:
: 193176 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-09-04 12:19 UTC by Georg Bege
Modified: 2009-10-14 01:03 UTC (History)
3 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 Georg Bege 2006-09-04 12:19:12 UTC
I got the same problem today.
I had eix 0.7.2 whether stable or not it doesnt matters.
Always segfault with update-eix.

+++ This bug was initially created as a clone of Bug #112826 +++

When eix is compiled using the patched hardened gcc, update-eix can't run (see 
below). When compiled with the vanilla-gcc it works. 

Reproducible: Always
Steps to Reproduce:
Knoppix / # gcc-config -l  
 [1] i686-pc-linux-gnu-3.3.6  
 [2] i686-pc-linux-gnu-3.3.6-hardenednopie  
 [3] i686-pc-linux-gnu-3.3.6-hardenednopiessp  
 [4] i686-pc-linux-gnu-3.3.6-hardenednossp  
 [5] i686-pc-linux-gnu-3.3.6-vanilla  
 [6] i686-pc-linux-gnu-3.4.4 *  
 [7] i686-pc-linux-gnu-3.4.4-hardenednopie  
 [8] i686-pc-linux-gnu-3.4.4-hardenednopiessp  
 [9] i686-pc-linux-gnu-3.4.4-hardenednossp  
 [10] i686-pc-linux-gnu-3.4.4-vanilla  
Knoppix / # emerge eix  
...  
 
Knoppix / # update-eix 
Reading Portage settings .. 
Building database (/var/cache/eix) from scratch .. 
Received SIGSEGV - you probably found a bug in eix. 
Please post the output of eix -V along with your bugreport. 
Sorry for the inconvenience. 
Knoppix / # gcc-config 10 
 * Switching native-compiler to i686-pc-linux-gnu-3.4.4-vanilla ...                                                                                                                          
[ ok ] 
 
 * If you intend to use the gcc from the new profile in an already 
 * running shell, please remember to do: 
 
 *   # source /etc/profile 
 
Knoppix / # env-update && source /etc/profile 
>>> Regenerating /etc/ld.so.cache... 
Knoppix / # emerge eix 
... 
Knoppix / # update-eix 
Reading Portage settings .. 
Building database (/var/cache/eix) from scratch .. 
[0] /usr/portage/ (cache: flat) 
     Reading 100% 
[1] /usr/local/portage (cache: none) 
     Reading 100% 
Applying masks .. 
Database contains 10282 packages in 144 categories. 
Knoppix / # 
Actual Results:  
SEGV 

Expected Results:  
!SEGV 

Knoppix / # emerge info 
Portage 2.0.53_rc7 (hardened/x86/2.6, gcc-3.4.4, glibc-2.3.5-r3, 2.6.12 i686) 
================================================================= 
System uname: 2.6.12 i686 Intel(R) Pentium(R) M processor 1.60GHz 
Gentoo Base System version 1.12.0_pre10 
dev-lang/python:     2.3.5, 2.4.2 
sys-apps/sandbox:    1.2.13 
sys-devel/autoconf:  2.13, 2.59-r7 
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1 
sys-devel/binutils:  2.16.1 
sys-devel/libtool:   1.5.20-r1 
virtual/os-headers:  2.6.11-r2 
ACCEPT_KEYWORDS="x86 ~x86" 
AUTOCLEAN="yes" 
CBUILD="i686-pc-linux-gnu" 
CFLAGS="-O2 -march=i686 -fomit-frame-pointer -pipe" 
CHOST="i686-pc-linux-gnu" 
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config /usr/share/config /var/qmail/control" 
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" 
CXXFLAGS="" 
DISTDIR="/usr/portage/distfiles" 
FEATURES="autoconfig distlocks sandbox sfperms strict" 
GENTOO_MIRRORS="http://distfiles.gentoo.org 
http://distro.ibiblio.org/pub/linux/distributions/gentoo" 
LANG="de_DE@euro" 
PKGDIR="/usr/portage//packages/x86/" 
PORTAGE_TMPDIR="/var/tmp" 
PORTDIR="/usr/portage/" 
PORTDIR_OVERLAY="/usr/local/portage" 
SYNC="rsync://rsync.gentoo.org/gentoo-portage" 
USE="acl adns apache2 bash-completion berkdb bzip2 crypt curl curl-wrappers 
expat ftp hardened hardened-php imagemagick imlib jpeg maildir mysql ncurses 
nptl nptlonly pam pcre perl pic png posix prelude python readline samba 
sockets ssl tcpd unicode vhosts x86 xml2 zlib userland_GNU kernel_linux 
elibc_glibc" 
Unset:  ASFLAGS, CTARGET, LC_ALL, LDFLAGS, LINGUAS, MAKEOPTS
Comment 1 Georg Bege 2006-09-04 12:21:54 UTC
root@coruscant ~ # emerge --info
Portage 2.1-r2 (hardened/x86/2.6, gcc-3.4.6, glibc-2.3.6-r4, 2.6.11-hardened-r15-coruscant i686)
=================================================================
System uname: 2.6.11-hardened-r15-coruscant i686 Intel(R) Celeron(R) CPU 2.40GHz
Gentoo Base System version 1.12.4
ccache version 2.3 [enabled]
app-admin/eselect-compiler: [Not Present]
dev-lang/python:     2.3.5-r2, 2.4.3-r1
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     2.3
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.59-r7
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.16.1-r3
sys-devel/gcc-config: 1.3.13-r3
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.8.1-r1, 2.6.11-r2
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS=" -mfpmath=387 -mmmx -msse -msse2 -fforce-addr -falign-functions=4 -fprefetch-loop-arrays -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /etc/mail/dspam /usr/share/config /var/bind /var/qmail /var/qmail/alias /var/qmail/control /var/run/dspam /var/vpopmail /var/vpopmail/domains /var/vpopmail/etc"
CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/init.d /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS=""
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig buildpkg ccache distlocks fixpackages metadata-transfer sandbox sfperms strict"
GENTOO_MIRRORS="ftp://ftp.ipv6.uni-muenster.de/pub/linux/distributions/gentoo ftp://ftp6.uni-erlangen.de/pub/mirrors/gentoo"
LANG="de_DE.utf8"
LC_ALL="de_DE.utf8"
LDFLAGS="-Wl,-Ol -Wl,--enable-new-dtags -Wl,--sort-common -s"
LINGUAS="EN"
MAKEOPTS="-j2"
PKGDIR="/usr/portage//packages/x86/"
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"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="acl berkdb bzip2 caps crypt curl dlloader elibc_glibc expat gd gdbm gif gmp gnutls hardened idn ipv6 jpeg kernel_linux linguas_EN mhash mysql ncurses nls pam pcre perl php pic png python readline slang socks5 ssl tcpd threads tiff truetype udev unicode usb userland_GNU userlocales x86 xml2 xmlreader xmlwriter xorg xsl zlib input_devices_mouse input_devices_keyboard"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, PORTAGE_RSYNC_EXTRA_OPTS

root@coruscant ~ # uname -a
Linux coruscant 2.6.11-hardened-r15-coruscant #1 Mon Sep 5 01:58:54 CEST 2005 i686 Intel(R) Celeron(R) CPU 2.40GHz GNU/Linux

root@coruscant ~ # gcc-config -l
 [1] i686-pc-linux-gnu-3.4.6 *
 [2] i686-pc-linux-gnu-3.4.6-hardenednopie
 [3] i686-pc-linux-gnu-3.4.6-hardenednopiessp
 [4] i686-pc-linux-gnu-3.4.6-hardenednossp
 [5] i686-pc-linux-gnu-3.4.6-vanilla

Knoppix / # update-eix 
Reading Portage settings .. 
Building database (/var/cache/eix) from scratch .. 
Received SIGSEGV - you probably found a bug in eix. 
Please post the output of eix -V along with your bugreport. 
Sorry for the inconvenience. 
Comment 2 Jakub Moc (RETIRED) gentoo-dev 2006-09-04 12:30:11 UTC
This is NOT a Gentoo bugzilla product bug, read the descriptions.
Comment 3 Martin Väth 2006-09-04 17:12:59 UTC
I try to re-assign this bug to the hardened team, but maybe the toolchain team is more correct, because the bug might also be related to the fix of #99192. In any case, it is certainly not a particular problem of eix:

The function "std::unique" (for vectors) crashes with gcc-3.4.6-r1 hardened on x86 when used with -O0. It works well with -O1 or -O2 or vanilla. Surprisingly, it does also not work on hardened when manually all optimizations mentioned in the gcc manpage for -O1 are switched on. The backtrace (even when compiled with -g -ggdb3) is completely useless. Here is some sort of minimal code example:

#include <vector>
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
	vector<int> test;
	test.push_back(1);
	cout << "Before std::unique\n";
	unique(test.begin(), test.end());
	cout << "This is not reached with -O0 on hardened\n";
	return 0;
}

To the original poster: Setting -O2 or at least -O1 in CXXFLAGS (and CFLAGS) should solve the problem, although I don't know why.
Comment 4 Georg Bege 2006-09-04 23:30:16 UTC
(In reply to comment #3)
> I try to re-assign this bug to the hardened team, but maybe the toolchain team
> is more correct, because the bug might also be related to the fix of #99192. In
> any case, it is certainly not a particular problem of eix:
> 
> The function "std::unique" (for vectors) crashes with gcc-3.4.6-r1 hardened on
> x86 when used with -O0. It works well with -O1 or -O2 or vanilla. Surprisingly,
> it does also not work on hardened when manually all optimizations mentioned in
> the gcc manpage for -O1 are switched on. The backtrace (even when compiled with
> -g -ggdb3) is completely useless. Here is some sort of minimal code example:
> 
> #include <vector>
> #include <iostream>
> 
> using namespace std;
> 
> int main(int argc, char** argv)
> {
>         vector<int> test;
>         test.push_back(1);
>         cout << "Before std::unique\n";
>         unique(test.begin(), test.end());
>         cout << "This is not reached with -O0 on hardened\n";
>         return 0;
> }
> 
> To the original poster: Setting -O2 or at least -O1 in CXXFLAGS (and CFLAGS)
> should solve the problem, although I don't know why.
> 

Damn thank you dude this worked out :)
Well I really dont know why it just appeared yesterday,
I guess I did change a bit at the CFLAGS section though.
That was the trigger I guess.
But we have a workaround ...
Comment 5 Maxim Chugunov 2007-08-06 23:01:01 UTC
*** Bug 187946 has been marked as a duplicate of this bug. ***
Comment 6 Martin Väth 2007-09-20 14:12:38 UTC
*** Bug 193176 has been marked as a duplicate of this bug. ***
Comment 7 Gordon Malm (RETIRED) gentoo-dev 2009-10-14 01:03:11 UTC
Should be fixed, re-open if not.