Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 533882 - app-emulation/qemu: ELF loaders should dynamically allocate target pages to hold command line / environment
Summary: app-emulation/qemu: ELF loaders should dynamically allocate target pages to h...
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: ARM Linux
: Normal normal (vote)
Assignee: Gentoo QEMU Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-29 00:49 UTC by Michael Jones
Modified: 2017-05-04 18:45 UTC (History)
3 users (show)

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


Attachments
build.log.gz (build.log.gz,46.15 KB, application/gzip)
2014-12-29 00:55 UTC, Michael Jones
Details
qemu-max-args.patch (qemu-max-args.patch,505 bytes, patch)
2015-03-31 18:48 UTC, Michael Jones
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Jones 2014-12-29 00:49:52 UTC
On a qemu-arm binfmt chroot (well, using systemd-nspawn, but same thing)


emerging binutils fails with this error:

make[4]: Entering directory '/var/tmp/portage/sys-devel/binutils-2.24-r3/work/build/gold/testsuite'
(for i in `seq 1 70000`; do \
   echo "int var_$i __attribute__((section(\"section_$i\"))) = $i;"; \
 done) > many_sections_define.h.tmp
make[4]: execvp: /bin/sh: Argument list too long
Makefile:4730: recipe for target 'many_sections_define.h' failed
make[4]: *** [many_sections_define.h] Error 127





armv6j-hardfp ~ # emerge --info binutils
Portage 2.2.8-r2 (default/linux/arm/13.0/armv6j, gcc-4.8.3, glibc-2.19-r1, 3.15.10-hardened-r1 armv7l)
=================================================================
                         System Settings
=================================================================
System uname: Linux-3.15.10-hardened-r1-armv7l-with-gentoo-2.2
KiB Mem:     3712780 total,    964572 free
KiB Swap:   10485756 total,  10474004 free
Timestamp of tree: Mon, 22 Dec 2014 01:00:01 +0000
ld GNU ld (Gentoo 2.24 p1.4) 2.24
app-shells/bash:          4.2_p53
dev-lang/perl:            5.18.2-r2
dev-lang/python:          2.7.7, 3.3.5-r1, 3.4.1
dev-util/pkgconfig:       0.28-r1
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.11.6-r1, 1.13.4
sys-devel/binutils:       2.24-r3
sys-devel/gcc:            4.8.3
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4.2-r1
sys-devel/make:           4.0-r1
sys-kernel/linux-headers: 3.16 (virtual/os-headers)
sys-libs/glibc:           2.19-r1
Repositories: gentoo
ACCEPT_KEYWORDS="arm"
ACCEPT_LICENSE="* -@EULA"
CBUILD="armv6j-hardfloat-linux-gnueabi"
CFLAGS="-O2 -pipe -march=armv6j -mfpu=vfp -mfloat-abi=hard"
CHOST="armv6j-hardfloat-linux-gnueabi"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -march=armv6j -mfpu=vfp -mfloat-abi=hard"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS=" --jobs --keep-going --newuse --deep --backtrack=3000 --complete-graph --with-bdeps=y"
FCFLAGS="-O2 -pipe -march=armv6j"
FEATURES="assume-digests binpkg-logs buildpkg clean-logs compress-build-logs compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles installsources merge-sync news parallel-fetch parallel-install preserve-libs protect-owned sandbox sfperms split-elog split-log splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -march=armv6j"
GENTOO_MIRRORS="http://mirrors.rit.edu/gentoo/ http://mirror.datapipe.net/gentoo http://mirror.usu.edu/mirrors/gentoo/ http://gentoo.mirrors.hoobly.com/ http://gentoo.netnitco.net"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j10"
PKGDIR="/usr/portage/packages"
PORTAGE_COMPRESS="xz"
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="/usr/portage"
PORTDIR_OVERLAY=""
USE="acl arm autoipd avahi berkdb bzip2 clang cli cracklib crypt cxx dbus dri fortran gd gdbm gudev iconv ipv6 mdnsresponder-compat modules ncurses networkmanager nls nptl openmp pam pcre python readline samba session ssl systemd tcpd udisks unicode xattr zeroconf zlib" 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="df interface irq load memory rrdtool swap syslog" 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" GRUB_PLATFORMS="coreboot efi-32 efi-64 emu qemu pc" INPUT_DEVICES="evdev synaptics mouse keyboard" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en en_US" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" QEMU_SOFTMMU_TARGETS="arm aarch64 i386 x86_64" QEMU_USER_TARGETS="arm aarch64 i386 x86_64" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="modesetting fbdev" 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, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, SYNC, USE_PYTHON

=================================================================
                        Package Settings
=================================================================

sys-devel/binutils-2.24-r3 was built with the following:
USE="cxx nls zlib (-multislot) -multitarget -static-libs -test -vanilla"











Reproducible: Always
Comment 1 Michael Jones 2014-12-29 00:55:20 UTC
Created attachment 392610 [details]
build.log.gz
Comment 2 SpanKY gentoo-dev 2015-02-09 15:49:55 UTC
i imagine it's qemu related
Comment 3 Eugene Cormier 2015-03-31 16:41:01 UTC
there is an answer how to fix this here:
https://blogs.gentoo.org/calchan/2015/03/11/binsh-argument-list-too-long/

maybe we can get a patch?
Comment 4 Michael Jones 2015-03-31 18:48:30 UTC
Created attachment 400298 [details, diff]
qemu-max-args.patch

Drop into /etc/portage/patches/app-emulation/qemu/

and then rebuild qemu.

Have not verified that this actually fixes the problem yet.
Comment 5 SpanKY gentoo-dev 2015-03-31 21:26:48 UTC
the linux kernel itself changed from a static limit to dynamic on MMU systems.  qemu should do the same.  increasing that constant is a workaround, but it's not entirely free -- it will attempt to allocate that many pages and make it available in the target memory space.  even if you only need ~1 page of data normally.
Comment 6 Michael Jones 2015-04-02 06:30:14 UTC
Hopefully Qemu addresses the dynamic allocation problem soon then. Even bumping it to 64 wasn't enough for LibreOffice. 256 seemed to be enough though.
Comment 7 Denis Dupeyron (RETIRED) gentoo-dev 2015-04-05 17:38:33 UTC
(In reply to SpanKY from comment #5)
> the linux kernel itself changed from a static limit to dynamic on MMU
> systems.  qemu should do the same.  increasing that constant is a
> workaround, but it's not entirely free -- it will attempt to allocate that
> many pages and make it available in the target memory space.  even if you
> only need ~1 page of data normally.

Oh, now I understand why I was CCed on this bug. Do you want me to add a fix to the ebuild to work around the issue? And if so, do you prefer a patch or a sed? I have looked at discussions about it on upstream's mailing list, and it doesn't look like we're getting a dynamic solution anytime soon. But you may know more than me about this.

If you want me to do it then I'll bisect the minimum required value for binutils to build. I think minimizing the value should also minimize the amount of potential issues we could get due to increasing it. In my blog post I just doubled the kernel value because all I wanted was for binutils to build. So far it's been the only problematic package, and I have tried a truckload of them, even some very non-embedded ones. Using my crossroot tool (which I should release, someday I'll eventually stop slacking) makes this bisecting easy.

Denis.
Comment 8 SpanKY gentoo-dev 2015-04-06 20:05:47 UTC
(In reply to Denis Dupeyron from comment #7)

nah, i'm not really looking for a workaround patch here.  just cc-ing you since your post covered the issue and you were interested in doing more, or wanted to follow along.
Comment 9 Matthias Maier gentoo-dev 2017-05-04 18:45:27 UTC
This was fixed upstream by commit

commit 59baae9a626396a3a05840279084c4bf2beb8f40
Author: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Date:   Wed Sep 2 03:38:53 2015 +0200

    linux-user: remove MAX_ARG_PAGES limit
    
    Instead of creating a temporary copy for the whole environment and
    the arguments, directly copy everything to the target stack.
    
    For this to work, we have to change the order of stack creation and
    copying the arguments.
    
    Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
    Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
    Signed-off-by: Riku Voipio <riku.voipio@linaro.org>