Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 451326

Summary: app-emulation/qemu-user-1.2.2: epoll syscall generates events for unregistered file descriptors inside arm chroot
Product: Portage Development Reporter: Kevin Wilson <kwilson>
Component: CoreAssignee: Luca Barbato <lu_zero>
Status: RESOLVED WONTFIX    
Severity: normal CC: dev-portage, kripton, kwilson, qemu+disabled
Priority: Normal    
Version: unspecified   
Hardware: ARM   
OS: Linux   
URL: http://lists.gnu.org/archive/html/qemu-devel/2011-02/msg01887.html
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 508098    
Bug Blocks:    
Attachments: 'git bisect log' output
output of 'runtests.sh' in portage git repo for commit b986bcdd49c5523ffe6972377071d556a819c776
workaround: disable epoll in portage

Description Kevin Wilson 2013-01-10 23:26:34 UTC
For a few months, I had been using the previous stable version, portage-2.1.11.31, in an arm chroot on i686 to compile packages for the OpenPandora and Raspberry Pi.  That version does not support the newest EAPI and has recently been removed from the tree.  Unfortunately, the version that replaced it, portage-2.1.11.31, no longer works properly in the same configuration.  The 'merge' step fails with something like 'KeyError: 1702043759'. Every other more recent version that I have tried has had the same problem, including today's 2.2.0_alpha150 tag.  

I cloned the portage git repository and ran 'git bisect' to track down the problematic commit by running 'runtests.sh'.  I will attach the output produced by 'runtests.sh' of commit b986bcdd49c5523ffe6972377071d556a819c776, where the problem first appears, and the output of 'git bisect log'.

Emerged packages seem to merge properly and binpkgs are built, but an empty /var/tmp/portage/cat-egory/package directory containing only a lockfile is left behind.

Reproducible: Always

Steps to Reproduce:
1. Install qemu-user with qemu_user_targets_arm enabled.
2. Create an arm7a chroot and copy the qemu-static-arm* binaries to its /usr/bin.
3. Run /etc/init.d/qemu-binfmt on the host.
4. Enter the arm chroot and emerge something.
Actual Results:  
Package merges, but portage crashes and does not remove its /var/tmp/portage/cat-egory/package directory, although it removes everything inside except a lockfile (including build.log, etc.).  A traceback is displayed:

>>> Installing (1 of 1) sys-libs/ncurses-5.9-r2
qemu: Unsupported syscall: 373
qemu: Unsupported syscall: 373
Traceback (most recent call last):
  File "/usr/bin/emerge", line 51, in <module>
    retval = emerge_main()
  File "/usr/lib/portage/pym/_emerge/main.py", line 1044, in emerge_main
    gc_locals=locals().clear)
  File "/usr/lib/portage/pym/_emerge/actions.py", line 3892, in run_action
    myopts, myaction, myfiles, spinner)
  File "/usr/lib/portage/pym/_emerge/actions.py", line 471, in action_build
    retval = mergetask.merge()
  File "/usr/lib/portage/pym/_emerge/Scheduler.py", line 1011, in merge
    rval = self._merge()
  File "/usr/lib/portage/pym/_emerge/Scheduler.py", line 1396, in _merge
    self._main_loop()
  File "/usr/lib/portage/pym/_emerge/Scheduler.py", line 1373, in _main_loop
    self._event_loop.iteration()
  File "/usr/lib/portage/pym/portage/util/_eventloop/EventLoop.py", line 259, in iteration
    x = event_handlers[f]
KeyError: 900929539

Expected Results:  
Package merges and portage terminates cleanly without errors.

arm $ emerge --info
Portage 2.2.0_alpha150 (default/linux/arm/10.0/armv7a, gcc-4.6.3, glibc-2.15-r3, 3.3.8-gentoo armv7l)
=================================================================
System uname: Linux-3.3.8-gentoo-armv7l-with-gentoo-2.1
Timestamp of tree: Thu, 10 Jan 2013 19:30:01 +0000
ld GNU ld (GNU Binutils) 2.22
app-shells/bash:          4.2_p37
dev-lang/python:          2.7.3-r2, 3.2.3
dev-util/cmake:           2.8.9
dev-util/pkgconfig:       0.27.1
sys-apps/baselayout:      2.1-r1
sys-apps/openrc:          0.11.8
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.68
sys-devel/automake:       1.11.6
sys-devel/binutils:       2.22-r1
sys-devel/gcc:            4.5.4, 4.6.3
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r3                                                                                
sys-kernel/linux-headers: 3.4-r2 (virtual/os-headers)                                                            
sys-libs/glibc:           2.15-r3                                                                                
Repositories: gentoo pandora                                                                                     
ACCEPT_KEYWORDS="arm"                                                                                            
ACCEPT_LICENSE="* -@EULA"                                                                                        
CBUILD="armv7a-hardfloat-linux-gnueabi"                                                                          
CFLAGS="-O2 -pipe -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=hard"                                   
CHOST="armv7a-hardfloat-linux-gnueabi"                                                                           
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt /usr/share/openvpn/easy-rsa"                                 
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"                                                                  
CXXFLAGS="-O2 -pipe -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=hard"                                 
DISTDIR="/usr/portage/distfiles"                                                                                 
FCFLAGS="-O2 -pipe -march=armv7-a"                                                                               
FEATURES="assume-digests binpkg-logs buildpkg config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"                                                                                         
FFLAGS="-O2 -pipe -march=armv7-a"                                                                                
GENTOO_MIRRORS="http://distfiles.gentoo.org"                                                                     
LDFLAGS="-Wl,-O1 -Wl,--as-needed"                                                                                
MAKEOPTS="-j3"                                                                                                   
PKGDIR="/usr/portage/packages"                                                                                   
PORTAGE_CONFIGROOT="/"                                                                                           
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --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="/usr/local/portage"                                                                             
SYNC="rsync://rsync.gentoo.org/gentoo-portage"                                                                   
USE="X acl alsa arm bash-completion berkdb bindist bzip2 cjk cli cracklib crypt cups cxx dbus fortran gdbm gpm iconv ipv6 modules mudflap ncurses neon nls nptl openmp pam pcre png pppd readline session ssl tcpd truetype unicode vim-syntax zlib" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" 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" 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 ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en ja" PHP_TARGETS="php5-3" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_2" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="omapfb 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, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

i686 host $ emerge --info

Portage 2.2.0_alpha130 (unavailable, gcc-4.5.4, glibc-2.15-r2, 3.3.8-gentoo i686)
=================================================================
System uname: Linux-3.3.8-gentoo-i686-Intel-R-_Core-TM-2_Duo_CPU_T7700_@_2.40GHz-with-gentoo-2.1
Timestamp of tree: Unknown
dev-lang/python:          2.6.6-r2::gentoo, 2.7.3-r2::gentoo, 3.1.4-r3::gentoo, 3.2.3::gentoo
sys-devel/autoconf:       2.68::gentoo
sys-devel/automake:       1.11.6::gentoo
sys-devel/binutils:       2.22-r1::gentoo
sys-devel/libtool:        2.4-r1::gentoo
sys-kernel/linux-headers: 3.1::gentoo (virtual/os-headers)
Repositories: x-portage uschep
Installed sets: @base
ACCEPT_LICENSE="* -@EULA"
CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage/uschep"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="mmx sse sse2"
Unset:  ACCEPT_KEYWORDS, EMERGE_DEFAULT_OPTS, PORTAGE_BUNZIP2_COMMAND
Comment 1 Kevin Wilson 2013-01-10 23:29:18 UTC
Created attachment 335122 [details]
'git bisect log' output
Comment 2 Kevin Wilson 2013-01-10 23:48:08 UTC
My apologies.  The original post should read "I had been using the previous stable version, portage-2.1.11.9, ...".  To be clear: portage-2.1.11.9 worked, but later versions do not.
Comment 3 Kevin Wilson 2013-01-11 00:03:00 UTC
Created attachment 335126 [details]
output of 'runtests.sh' in portage git repo for commit b986bcdd49c5523ffe6972377071d556a819c776
Comment 4 Zac Medico gentoo-dev 2013-01-11 17:03:21 UTC
(In reply to comment #0)
> >>> Installing (1 of 1) sys-libs/ncurses-5.9-r2
> qemu: Unsupported syscall: 373

This looks more like a fault of qemu than a portage bug. How could it be acceptable to ignore a syscall and just print a warning message like this?
Comment 5 Kevin Wilson 2013-01-11 17:16:58 UTC
(In reply to comment #4)
> (In reply to comment #0)
> > >>> Installing (1 of 1) sys-libs/ncurses-5.9-r2
> > qemu: Unsupported syscall: 373
> 
> This looks more like a fault of qemu than a portage bug. How could it be
> acceptable to ignore a syscall and just print a warning message like this?

I thought so too.  I don't remember whether or not the warnings appeared with portage 2.1.11.9.  However, the merge failures are new, and the change to portage has rendered my build setup effectively useless.  I would really appreciate some sort of workaround until the combination of qemu and portage works again.
Comment 6 Zac Medico gentoo-dev 2013-01-11 17:23:04 UTC
Created attachment 335244 [details, diff]
workaround: disable epoll in portage
Comment 7 Kevin Wilson 2013-01-11 20:06:14 UTC
(In reply to comment #6)
> Created attachment 335244 [details, diff] [details, diff]
> workaround: disable epoll in portage

I applied this patch to portage-2.1.11.31 and 'emerge' finishes cleanly again.  Thanks!  I'll add it to my local overlay.

FWIW, I still see the qemu syscall warnings:

>>> Installing (1 of 1) sys-libs/gpm-1.20.6
qemu: Unsupported syscall: 373
qemu: Unsupported syscall: 373
>>> Auto-cleaning packages...
Comment 8 Zac Medico gentoo-dev 2013-01-12 08:45:32 UTC
(In reply to comment #0)
> Steps to Reproduce:
> 1. Install qemu-user with qemu_user_targets_arm enabled.

What version of qemu-user is this? Note that qemu-user is now masked, and app-emulation/qemu with QEMU_USER_TARGETS is the replacement, as recently announced:

> Subject: [gentoo-dev] app-emulation/qemu-user mask
> From: Doug Goldstein <cardoe@gentoo.org>
> To: gentoo-dev@lists.gentoo.org, gentoo-dev-announce@lists.gentoo.org
>
> Just wanted to give everyone a heads up. app-emulation/qemu provides
> all the functionality of app-emulation/qemu-user without all the
> outstanding security bugs and issues the package has. For users using
> a cross chroot, I encourage you to look at QEMU_USER_TARGETS. I
> presently use an arm chroot with app-emulation/qemu. Should there
> truly be a missing feature, open a bug and I'll fix it. The only item
> I'm aware of that app-emulation/qemu does not have is the binfmt
> initscript. But I plan on adding that to the unstable version shortly.
> 
> If there are no objections for 30 days, I'll send a treecleaner notice
> in 30 days and remove it 30 days after that (60 days from now).
Comment 9 Doug Goldstein (RETIRED) gentoo-dev 2013-01-14 02:49:02 UTC
This issue exists because app-emulation/qemu-user is out of date and not updated. This is exactly one of the reasons why I've masked it and recommended people switch to app-emulation/qemu.
Comment 10 Kevin Wilson 2013-01-20 07:50:06 UTC
I'm using app-emulation/qemu-user-1.1.0-r1.  I'll switch to qemu and retain the 
qemu-binfmt init script.  Thanks for your attention.
Comment 11 Zac Medico gentoo-dev 2013-02-26 00:00:27 UTC
(In reply to comment #0)
>   File "/usr/lib/portage/pym/portage/util/_eventloop/EventLoop.py", line
> 259, in iteration
>     x = event_handlers[f]
> KeyError: 900929539

I've experienced this problem with qemu-user-1.2.2, and I've committed the following workaround for portage:

http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=071440cc30cc5a625317d5bd47e86c2bfdd8a940

It seems to be a harmless quirk if we simply ignore the extra events that are generated.

Apparently the "qemu: Unsupported syscall: 373" messages are for some other syscall, probably syncfs, since the above patch would not work unless epoll was also working.
Comment 12 SpanKY gentoo-dev 2014-05-30 04:40:59 UTC
qemu-user has been removed from the tree as its functionality has been superseded by the combined app-emulation/qemu package.  if you find the qemu package does not support something that the qemu-user package did, please file a new bug explicitly detailing things so we can get it added.