Hi, when using STL (particulary vector class) with hardened gcc, I get segmentation faults. $ cat test.cpp #include <iostream> #include <vector> using namespace std; int main(int argc, char** argv) { vector<int> v; v.push_back( 23 ); v.push_back( -1 ); v.push_back( 9999 ); v.push_back( 0 ); v.push_back( 4 ); cout << "Before sorting: "; for( unsigned int i = 0; i < v.size(); i++ ) { cout << v[i] << " "; } cout << endl; sort( v.begin(), v.end() ); cout << "After sorting: "; for( unsigned int i = 0; i < v.size(); i++ ) { cout << v[i] << " "; } cout << endl; return 0; } # gcc-config i686-pc-linux-gnu-3.4.5 * Switching native-compiler to i686-pc-linux-gnu-3.4.5 ... [ ok ] $ g++ test.cpp -o test $ ./test Before sorting: 23 -1 9999 0 4 Segmentation fault # gcc-config i686-pc-linux-gnu-3.4.5-vanilla * Switching native-compiler to i686-pc-linux-gnu-3.4.5-vanilla ... >>> Regenerating /etc/ld.so.cache... [ ok ] * If you intend to use the gcc from the new profile in an already * running shell, please remember to do: * # source /etc/profile $ source /etc/profile $ g++ test.cpp -o test $ ./test Before sorting: 23 -1 9999 0 4 After sorting: -1 0 4 23 9999 $ g++ -v Reading specs from /usr/lib/gcc/i686-pc-linux-gnu/3.4.5/specs Reading specs from /usr/lib/gcc/i686-pc-linux-gnu/3.4.5/vanilla.specs Configured with: /var/tmp/portage/gcc-3.4.5-r1/work/gcc-3.4.5/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.4.5 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/3.4.5/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.5 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.5/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.5/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/3.4.5/include/g++-v3 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --disable-nls --with-system-zlib --disable-checking --disable-werror --disable-libunwind-exceptions --disable-multilib --disable-libgcj --enable-languages=c,c++,f77 --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu Thread model: posix gcc version 3.4.5 (Gentoo Hardened 3.4.5-r1, ssp-3.4.5-1.0, pie-8.7.9) $ emerge --info Portage 2.1_rc1-r2 (default-linux/x86/2006.0, gcc-3.4.5-vanilla, glibc-2.3.6-r3, 2.6.16-gentoo-r7 i686) ================================================================= System uname: 2.6.16-gentoo-r7 i686 Intel(R) Pentium(R) M processor 1400MHz Gentoo Base System version 1.6.14 dev-lang/python: 2.3.5-r2, 2.4.2-r1 dev-python/pycrypto: 2.0.1-r5 dev-util/ccache: [Not Present] 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-r1 sys-devel/binutils: 2.16.1 sys-devel/libtool: 1.5.22 virtual/os-headers: 2.6.11-r2 ACCEPT_KEYWORDS="x86" AUTOCLEAN="yes" CBUILD="i686-pc-linux-gnu" CFLAGS="-Os -march=pentium-m -pipe -fomit-frame-pointer" CHOST="i686-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.4/env /usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/kde/3/share/config /usr/lib/mozilla/defaults/pref /usr/share/X11/xkb /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /usr/share/xsessions /var/qmail/control" CONFIG_PROTECT_MASK="/etc/eselect/compiler /etc/gconf /etc/splash /etc/terminfo /etc/env.d" CXXFLAGS="-Os -march=pentium-m -pipe -fomit-frame-pointer" DISTDIR="/usr/portage/distfiles" FEATURES="autoconfig distlocks metadata-transfer sandbox sfperms strict" GENTOO_MIRRORS="http://trumpetti.atm.tut.fi/gentoo/ http://ftp-stud.fht-esslingen.de/pub/Mirrors/gentoo/ ftp://ftp-stud.fht-esslingen.de/pub/Mirrors/gentoo/ http://ftp.snt.utwente.nl/pub/os/linux/gentoo ftp://ftp.snt.utwente.nl/pub/os/linux/gentoo" LANG="en_US.utf8" MAKEOPTS="-j2" 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="/usr/local/portage /usr/local/xgl-coffee /usr/local/xgl-testing" SYNC="rsync://rsync.nl.gentoo.org/gentoo-portage" USE="X acpi alsa avi bluetooth bzip2 cairo cdr cups dbus dri dvd fam firefox foomaticdb gif glitz gnome gstreamer gtk gtk2 gtkhtml hardened icq jpeg mmx mono mozilla mozsvg mp3 mpeg ncurses nsplugin ogg opengl pam pda perl png pnp ppds quicktime sse ssl tcpd truetype trusted unicode usb vorbis win32codecs x86 xprint xv xvid elibc_glibc input_devices_keyboard input_devices_mouse kernel_linux userland_GNU video_cards_radeon" Unset: ASFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LDFLAGS, LINGUAS, PORTAGE_RSYNC_EXTRA_OPTS
Also this might be relevant http://forums.gentoo.org/viewtopic-t-340971.html
know bug. This is a dupe of something or another with vector sorting. The solution is to filter-flags -fno-stack-protector-all
ok, closing then as fixed.
Not sure that is actually is FIXED. I just pointed out a workaround. Honestly. SSP + gcc-3.4.x is kinda buggy with c++ code. Probably what would be ideal is to use something like this local CXXFLAGS="${CFLAGS} -fno-stack-protector-all" That would enable basic ssp but not the agressive parts on c++ code.
ok, the workaround works for me and I'll reopen the bug so that there is some track of the problem...
gcc-4.3.4 is stable on hardened and efforts will likely only be concentrated on new stuff. Closing as WONTFIX.