Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 503500 - sys-devel/binutils-2.24: building some packages w/-Os can lead to: stack_chk_fail_local.c:(.text+0x10): undefined reference to __stack_chk_fail
Summary: sys-devel/binutils-2.24: building some packages w/-Os can lead to: stack_chk_...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: x86 Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
: 528742 532192 534082 560438 (view as bug list)
Depends on: 560792
Blocks:
  Show dependency tree
 
Reported: 2014-03-05 11:18 UTC by Philipp Riegger
Modified: 2015-10-03 00:59 UTC (History)
10 users (show)

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


Attachments
build log (dev-qt:qtcore-4.8.5-r1:20140303-231845.log,134.24 KB, text/plain)
2014-03-05 17:09 UTC, Philipp Riegger
Details
emerge --info (emerge.info,19.29 KB, text/plain)
2014-12-01 20:45 UTC, Vincent-Xavier JUMEL
Details
MM: emerge --info (emerge --info,5.76 KB, text/plain)
2014-12-24 00:33 UTC, Matthew Millar
Details
jfindlay: emerge --info (emerge.info,5.50 KB, application/x-info)
2015-02-01 20:39 UTC, Justin Findlay
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Riegger 2014-03-05 11:18:46 UTC
I cannot compile qtcore on my hardened ~x86 box. I did "emerge -ev @system @world", which did not help. Setting gcc to vanilla using gcc-config did not help either.

Reproducible: Always

Steps to Reproduce:
1. emerge -1v dev-qt/qtcore

Actual Results:  
In file included from ../3rdparty/harfbuzz/src/harfbuzz-shaper-all.cpp:25:0:
../3rdparty/harfbuzz/src/harfbuzz-shaper.cpp: In function ‘HB_Bool HB_OpenTypePosition(HB_ShaperItem*, int, HB_Bool)’:
../3rdparty/harfbuzz/src/harfbuzz-shaper.cpp:1322:60: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 while (face->tmpLogClusters[stringIndex] < intermediateIndex) {
                                                            ^
io/qprocess_unix.cpp: In member function ‘void QProcessPrivate::execChild(const char*, char**, char**, char**)’:
io/qprocess_unix.cpp:771:29: warning: ignoring return value of ‘int chdir(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
         QT_CHDIR(workingDir);
                             ^
io/qprocess_unix.cpp: In static member function ‘static bool QProcessPrivate::startDetached(const QString&, const QStringList&, const QString&, qint64*)’:
io/qprocess_unix.cpp:1375:62: warning: ignoring return value of ‘int chdir(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
                 QT_CHDIR(encodedWorkingDirectory.constData());
                                                              ^
io/qprocess_unix.cpp:1428:22: warning: ignoring return value of ‘int chdir(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
         QT_CHDIR("/");
                      ^
kernel/qeventdispatcher_glib.cpp: In constructor ‘QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext*)’:
kernel/qeventdispatcher_glib.cpp:302:13: warning: ‘void g_thread_init(gpointer)’ is deprecated (declared at /usr/include/glib-2.0/glib/deprecated/gthread.h:260) [-Wdeprecated-declarations]
             g_thread_init(NULL);
             ^
kernel/qeventdispatcher_glib.cpp:302:31: warning: ‘void g_thread_init(gpointer)’ is deprecated (declared at /usr/include/glib-2.0/glib/deprecated/gthread.h:260) [-Wdeprecated-declarations]
             g_thread_init(NULL);
                               ^
make -j1 -s 'AR=i686-pc-linux-gnu-ar cqs' CC=i686-pc-linux-gnu-gcc CXX=i686-pc-linux-gnu-g++ LINK=i686-pc-linux-gnu-g++ RANLIB=: STRIP=:
/usr/lib/libc_nonshared.a(stack_chk_fail_local.oS): In function `__stack_chk_fail_local':
stack_chk_fail_local.c:(.text+0x20): undefined reference to `__stack_chk_fail'
collect2: error: ld returned 1 exit status
Makefile:121: recipe for target '../../lib/libQtXml.so.4.8.5' failed
make: *** [../../lib/libQtXml.so.4.8.5] Error 1
 ^[[31;01m*^[[0m ERROR: dev-qt/qtcore-4.8.5-r1::gentoo failed (compile phase):
 ^[[31;01m*^[[0m   emake failed
 ^[[31;01m*^[[0m
 ^[[31;01m*^[[0m If you need support, post the output of `emerge --info '=dev-qt/qtcore-4.8.5-r1::gentoo'`,
 ^[[31;01m*^[[0m the complete build log and the output of `emerge -pqv '=dev-qt/qtcore-4.8.5-r1::gentoo'`.
 ^[[31;01m*^[[0m The complete build log is located at '/var/log/portage/dev-qt:qtcore-4.8.5-r1:20140303-231845.log'.
 ^[[31;01m*^[[0m For convenience, a symlink to the build log is located at '/var/tmp/portage/dev-qt/qtcore-4.8.5-r1/temp/build.log'.
 ^[[31;01m*^[[0m The ebuild environment file is located at '/var/tmp/portage/dev-qt/qtcore-4.8.5-r1/temp/environment'.
 ^[[31;01m*^[[0m Working directory: '/var/tmp/portage/dev-qt/qtcore-4.8.5-r1/work/qt-everywhere-opensource-src-4.8.5/src/xml'
 ^[[31;01m*^[[0m S: '/var/tmp/portage/dev-qt/qtcore-4.8.5-r1/work/qt-everywhere-opensource-src-4.8.5'


Expected Results:  
It compiles and works as expected.

Portage 2.2.8-r1 (hardened/linux/x86, gcc-4.8.2, glibc-2.18-r1, 3.13.5-hardened i686)
=================================================================
System uname: Linux-3.13.5-hardened-i686-Intel-R-_Xeon-R-_CPU_E3-1220L_V2_@_2.30GHz-with-gentoo-2.2
KiB Mem:     1028060 total,     28080 free
KiB Swap:    1001468 total,    804964 free
Timestamp of tree: Sat, 01 Mar 2014 03:15:01 +0000
ld GNU ld (GNU Binutils) 2.24
app-shells/bash:          4.2_p45-r1
dev-lang/python:          2.7.6, 3.3.4
dev-util/cmake:           2.8.12.2
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.12.4
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.69
sys-devel/automake:       1.13.4, 1.14.1
sys-devel/binutils:       2.24-r2
sys-devel/gcc:            4.8.2
sys-devel/gcc-config:     1.8
sys-devel/libtool:        2.4.2
sys-devel/make:           4.0-r1
sys-kernel/linux-headers: 3.13 (virtual/os-headers)
sys-libs/glibc:           2.18-r1
Repositories: gentoo stoile_overlay eigenlay gentoo-haskell mate-overlay sunrise
ACCEPT_KEYWORDS="x86 ~x86"
ACCEPT_LICENSE="* -@EULA"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-Os -pipe -mno-tls-direct-seg-refs -fno-omit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt /var/spool/munin-async/.ssh"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.5/ext-active/ /etc/php/cgi-php5.5/ext-active/ /etc/php/cli-php5.5/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="-Os -pipe -mno-tls-direct-seg-refs -fno-omit-frame-pointer"
DISTDIR="/var/cache/portage/distfiles"
EMERGE_DEFAULT_OPTS="--keep-going --alphabetical --binpkg-respect-use y --load-average=3 --with-bdeps y --dynamic-deps n"
FCFLAGS="-march=i686 -O2 -pipe"
FEATURES="assume-digests binpkg-logs buildpkg collision-protect compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=i686 -O2 -pipe"
GENTOO_MIRRORS="http://ftp-stud.fht-esslingen.de/pub/Mirrors/gentoo http://gentoo.inode.at/ http://distfiles.gentoo.org http://www.ibiblio.org/pub/Linux/distributions/gentoo"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j1 -s"
PKGDIR="/var/cache/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/var/cache/portage/tree"
PORTDIR_OVERLAY="/var/lib/layman/stoile /var/lib/layman/eigenlay /var/lib/layman/haskell /var/lib/layman/mate /var/lib/layman/sunrise"
SYNC="rsync://rsync.de.gentoo.org/gentoo-portage"
USE="acl berkdb bzip2 caps cli cracklib crypt cxx dri gmp gs hardened iconv idn ipv6 jpeg logrotate logwatch lzma lzo modules ncurses nls nptl pam pax_kernel pcre pic png readline session ssl svg tcpd tiff udev unicode urandom vhosts x86 xattr xtpax zlib" ABI_X86="32" 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" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd 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" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="aggregation apache cgroups conntrack contextswitch cpu curl curl_json curl_xml df disk entropy ethstat exec interface iptables irq load lvm memory mysql netlink network nginx openvpn perl ping processes protocols python rrdtool swap syslog tail tcpconns threshold uptime users vmem" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" 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, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 1 Davide Pesavento gentoo-dev 2014-03-05 15:41:42 UTC
Attach the full build log please.
Comment 2 Philipp Riegger 2014-03-05 17:09:36 UTC
Created attachment 371802 [details]
build log
Comment 3 Davide Pesavento gentoo-dev 2014-03-05 17:30:29 UTC
CC'ing hardened for advice.

Could it be related to https://bugzilla.redhat.com/show_bug.cgi?id=1028849 ?
Does it work without --as-needed?
Comment 4 Philipp Riegger 2014-03-06 16:30:02 UTC
LDFLAGS="-Wl,--no-as-needed" emerge -1v qtcore

This works for me.
Comment 5 Davide Pesavento gentoo-dev 2014-03-07 23:12:31 UTC
Yeah, definitely looks like https://bugzilla.redhat.com/show_bug.cgi?id=1028849
Reassigning to toolchain.
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-11-30 21:57:30 UTC
In the meantime, we certainly can add no-as-needed as a workaround in qtcore.
Comment 7 Davide Pesavento gentoo-dev 2014-11-30 22:33:55 UTC
Patches welcome.
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-11-30 23:33:33 UTC
  append-ldflags $(no-as-needed)

from flag-o-matic. I don't have Hardened, so I can't test :).
Comment 9 Davide Pesavento gentoo-dev 2014-11-30 23:40:23 UTC
NAK. This bug is triggered only under a specific set of conditions (hardened + x86? hardened + -Os? hardened + something else?), and seems to affect only a small percentage of users, so appending --no-as-needed must be conditional as well. I'm not interested in disabling it for everyone.
Comment 10 Vincent-Xavier JUMEL 2014-12-01 20:28:01 UTC
I don't use "hardened" profile but whith '--as-neeeded" I've triggerde the bug.
Comment 11 Davide Pesavento gentoo-dev 2014-12-01 20:37:01 UTC
(In reply to Vincent-Xavier JUMEL from comment #10)
> I don't use "hardened" profile but whith '--as-neeeded" I've triggerde the
> bug.

post your emerge --info please
Comment 12 Vincent-Xavier JUMEL 2014-12-01 20:45:33 UTC
Created attachment 390732 [details]
emerge --info

There you are !
Comment 13 Davide Pesavento gentoo-dev 2014-12-01 22:39:25 UTC
(In reply to Vincent-Xavier JUMEL from comment #12)
> Created attachment 390732 [details]
> emerge --info
> 
> There you are !

Interesting... you also use -Os, maybe that's triggering the bug. I'll try to reproduce with -Os locally.
Comment 14 Davide Pesavento gentoo-dev 2014-12-02 03:10:55 UTC
Ok, I can reproduce on non-hardened with ABI_X86=32 and CXXFLAGS=-Os, while -O2 works.

x86_64-pc-linux-gnu-g++ -m32 -Wl,--hash-style=gnu -Wl,-O1 -Wl,--as-needed -Wl,-rpath-link,/tmp/portage/dev-qt/qtcore-4.8.6-r1/work/qt-everywhere-opensource-src-4.8.6-abi_x86_32.x86/lib -Wl,--no-undefined -shared -Wl,-Bsymbolic-functions -Wl,-soname,libQtXml.so.4 -o libQtXml.so.4.8.6 .obj/release-shared/qdom.o .obj/release-shared/qxml.o   -L/tmp/portage/dev-qt/qtcore-4.8.6-r1/work/qt-everywhere-opensource-src-4.8.6-abi_x86_32.x86/lib -L/usr/lib32/qt4 -lQtCore -L/tmp/portage/dev-qt/qtcore-4.8.6-r1/work/qt-everywhere-opensource-src-4.8.6-abi_x86_32.x86/lib -lpthread
/usr/lib32/libc_nonshared.a(stack_chk_fail_local.oS): In function `__stack_chk_fail_local':
stack_chk_fail_local.c:(.text+0x10): undefined reference to `__stack_chk_fail'
collect2: error: ld returned 1 exit status
Comment 15 Magnus Granberg gentoo-dev 2014-12-10 20:29:21 UTC
*** Bug 532192 has been marked as a duplicate of this bug. ***
Comment 16 Matthew Millar 2014-12-24 00:33:38 UTC
Created attachment 392296 [details]
MM: emerge --info

I have also encountered this issue.

For the time-being, would adding 'replace-flags -Os -O2' to the QtCore ebuild suffice, whilst a bug is lodged with GCC?

Before that though, it would be ideal to test applying -O2 to ./src/xml/Makefile alone, to see whether qdom.cpp or qxml.cpp is the only instance of QtCores -Os incompatiblity.

emerge --info attached
Comment 17 Matthew Millar 2014-12-27 17:22:54 UTC
I have tested a compilation with LFLAGS=-lc manually entered into src/xml/Makefile, after configuration but before compilation.

The build completes successfully, including the libQtXml.

To patch the issue whilst it's investigated, is there an method using flags for when a build system is x86 and using CFLAGS="-Os" to make an ebuild sed -lc after LFLAGS in /src/xml/Makefile?
Comment 18 Justin Findlay 2015-02-01 20:39:39 UTC
Created attachment 395348 [details]
jfindlay: emerge --info
Comment 19 Justin Findlay 2015-02-01 20:41:10 UTC
I've encountered this as well.  My `emerge --info` is attached and here's the USE flags for qtcore:

# equery uses dev-qt/qtcore
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for dev-qt/qtcore-4.8.6-r1:
 U I
 + + abi_x86_32 : 32-bit (x86) libraries
 - - debug      : Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see http://www.gentoo.org/proj/en/qa/backtraces.xml
 + - exceptions : Add support for exceptions - like catching them inside the event loop (recommended by upstream)
 + - glib       : Enable dev-libs/glib eventloop support
 + + iconv      : Enable support for the iconv character set conversion library
 - - icu        : Enable ICU (Internationalization Components for Unicode) support, using dev-libs/icu
 + + qt3support : Enable the Qt3Support libraries for Qt4. Note that this does not mean you can compile pure Qt3 programs with Qt4.
 + + ssl        : Add support for Secure Socket Layer connections
Comment 20 Rick Farina (Zero_Chaos) gentoo-dev 2015-03-19 03:18:07 UTC
any reason not to solve this bug with "replace-flags -Os -O2"?  Even if this is a bug in the toolchain, I don't see why we need to leave the package unbuildable...
Comment 21 Davide Pesavento gentoo-dev 2015-03-22 02:04:34 UTC
(In reply to Rick Farina (Zero_Chaos) from comment #20)
> any reason not to solve this bug with "replace-flags -Os -O2"?  Even if this
> is a bug in the toolchain, I don't see why we need to leave the package
> unbuildable...

No reason, I simply forgot about this... Would it be better to append --no-as-needed or to replace -Os with -O2 ?

Also, is checking for "use x86 || use abi_x86_32" correct and enough?
Comment 22 Rick Farina (Zero_Chaos) gentoo-dev 2015-03-22 03:19:11 UTC
(In reply to Davide Pesavento from comment #21)
> (In reply to Rick Farina (Zero_Chaos) from comment #20)
> > any reason not to solve this bug with "replace-flags -Os -O2"?  Even if this
> > is a bug in the toolchain, I don't see why we need to leave the package
> > unbuildable...
> 
> No reason, I simply forgot about this... Would it be better to append
> --no-as-needed or to replace -Os with -O2 ?
> 
> Also, is checking for "use x86 || use abi_x86_32" correct and enough?

I think removing as-needed is much worse than forcing -Os back down to a more common -O2 (and I use -Os exclusively on all arches, mostly to find awesome bugs like this).

You can make it conditional like you suggest, or not.  Seems we are mostly fixing a build error and the smallest change is the best one, so conditional seems appropriate.
Comment 23 Rick Farina (Zero_Chaos) gentoo-dev 2015-03-22 21:04:39 UTC
I have replicated this issue on both qtcore-4.8.5-r2 and qtcore-4.8.6-r1.

Please fix both or nod and I'll apply the fix conditionally like you suggested.
Comment 25 Alexander Tsoy 2015-09-18 19:00:47 UTC
Probably a bug in binutils-2.24. See also bug 560438
Comment 26 Alexander Tsoy 2015-09-21 10:38:50 UTC
Well, I can confirm my guess. I removed workaround from qt4 eclasses and successfully reproduced this bug with binutils-2.24-r3. Upgrade to binutils-2.25.1-r1 fixed it for me.
Comment 27 SpanKY gentoo-dev 2015-09-21 17:34:47 UTC
*** Bug 560438 has been marked as a duplicate of this bug. ***
Comment 28 SpanKY gentoo-dev 2015-09-25 04:30:19 UTC
*** Bug 534082 has been marked as a duplicate of this bug. ***
Comment 29 SpanKY gentoo-dev 2015-09-25 04:30:40 UTC
*** Bug 528742 has been marked as a duplicate of this bug. ***
Comment 30 SpanKY gentoo-dev 2015-09-25 04:41:10 UTC
Alexander Tsoy: thanks for double checking.  we'll close this once arches finish stabilizing newer binutils in bug 560792.
Comment 31 SpanKY gentoo-dev 2015-10-03 00:59:31 UTC
2.25.1 is stable now, and we're not going to bother tracking down & backporting