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

Bug 607872

Summary: sys-apps/portage: AssertionError: setcpv recursion detected
Product: Portage Development Reporter: Paul Monsour <boulos>
Component: Core - Interface (emerge)Assignee: Portage team <dev-portage>
Status: RESOLVED FIXED    
Severity: major CC: boulos, conardcox
Priority: Normal Keywords: InVCS
Version: unspecified   
Hardware: AMD64   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 637452    
Attachments: Output from running "emerge --depclean"

Description Paul Monsour 2017-02-01 02:59:21 UTC
When I run "emerge --depclean", get a lot of screen output that ends with the line "AssertionError: setcpv recursion detected". I will post the entire output as an attachment after posting this.

Reproducible: Always

Steps to Reproduce:
1.run "emerge --depclean"
2.
3.
Actual Results:  
  File "/usr/lib/python-exec/python2.7/emerge", line 50, in <module>
    retval = emerge_main()
  File "/usr/lib64/python2.7/site-packages/_emerge/main.py", line 1224, in emerge_main
    return run_action(emerge_config)
  File "/usr/lib64/python2.7/site-packages/_emerge/actions.py", line 3166, in run_action
    emerge_config.args, spinner)
  File "/usr/lib64/python2.7/site-packages/_emerge/actions.py", line 2179, in action_uninstall
    scheduler=sched_iface)
  File "/usr/lib64/python2.7/site-packages/_emerge/actions.py", line 665, in action_depclean
    myopts, action, args_set, spinner)
  File "/usr/lib64/python2.7/site-packages/_emerge/actions.py", line 880, in calc_depclean
    success = resolver._complete_graph(required_sets={eroot:required_sets})
  File "/usr/lib64/python2.7/site-packages/_emerge/depgraph.py", line 6522, in _complete_graph
    if not self._create_graph(allow_unsatisfied=True):
  File "/usr/lib64/python2.7/site-packages/_emerge/depgraph.py", line 2401, in _create_graph
    allow_unsatisfied=allow_unsatisfied):
  File "/usr/lib64/python2.7/site-packages/_emerge/depgraph.py", line 3112, in _add_pkg_deps
    allow_unsatisfied):
  File "/usr/lib64/python2.7/site-packages/_emerge/depgraph.py", line 3128, in _add_pkg_dep_string
    allow_unsatisfied)
  File "/usr/lib64/python2.7/site-packages/_emerge/depgraph.py", line 3208, in _wrapped_add_pkg_dep_string
    pkg, dep_priority, root_config, selected_atoms[pkg]):
  File "/usr/lib64/python2.7/site-packages/_emerge/depgraph.py", line 3407, in _minimize_children
    root_config.root, atom, parent=parent)
  File "/usr/lib64/python2.7/site-packages/_emerge/depgraph.py", line 6360, in _select_pkg_from_installed
    self._equiv_ebuild_visible(pkg)]
  File "/usr/lib64/python2.7/site-packages/_emerge/depgraph.py", line 5482, in _equiv_ebuild_visible
    pkg.cpv, "ebuild", pkg.root_config, myrepo=pkg.repo)
  File "/usr/lib64/python2.7/site-packages/_emerge/depgraph.py", line 6591, in _pkg
    if not self._pkg_visibility_check(pkg) and \
  File "/usr/lib64/python2.7/site-packages/_emerge/depgraph.py", line 5624, in _pkg_visibility_check
    if pkg.visible:
  File "/usr/lib64/python2.7/site-packages/_emerge/Package.py", line 177, in visible
    self._visible = self._eval_visiblity(self.masks)
  File "/usr/lib64/python2.7/site-packages/_emerge/Package.py", line 171, in masks
    self._masks = self._eval_masks()
  File "/usr/lib64/python2.7/site-packages/_emerge/Package.py", line 403, in _eval_masks
    self.cpv, self._metadata)
  File "/usr/lib64/python2.7/site-packages/portage/package/ebuild/config.py", line 2036, in _getMissingLicenses
    cpv, metadata["USE"], metadata["LICENSE"], metadata["SLOT"], metadata.get('repository'))
  File "/usr/lib64/python2.7/site-packages/_emerge/Package.py", line 872, in __getitem__
    v = self._pkg._init_use()
  File "/usr/lib64/python2.7/site-packages/_emerge/Package.py", line 664, in _init_use
    use_str = self._get_pkgsettings()["PORTAGE_USE"]
  File "/usr/lib64/python2.7/site-packages/_emerge/Package.py", line 639, in _get_pkgsettings
    pkgsettings.setcpv(self)
  File "/usr/lib64/python2.7/site-packages/portage/package/ebuild/config.py", line 1384, in wrapper
    return f(self, *args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/portage/package/ebuild/config.py", line 1559, in setcpv
    self.puse = self._use_manager.getPUSE(cpv_slot)
  File "/usr/lib64/python2.7/site-packages/portage/package/ebuild/_config/UseManager.py", line 555, in getPUSE
    puse_matches = ordered_by_atom_specificity(cpdict, pkg)
  File "/usr/lib64/python2.7/site-packages/portage/package/ebuild/_config/helper.py", line 34, in ordered_by_atom_specificity
    bestmatch = best_match_to_list(pkg, keys)
  File "/usr/lib64/python2.7/site-packages/portage/dep/__init__.py", line 2066, in best_match_to_list
    for x in match_to_list(mypkg, mylist):
  File "/usr/lib64/python2.7/site-packages/portage/dep/__init__.py", line 2034, in match_to_list
    if x not in matches and match_from_list(x, pkgs):
  File "/usr/lib64/python2.7/site-packages/portage/dep/__init__.py", line 2349, in match_from_list
    use = getattr(x, "use", None)
  File "/usr/lib64/python2.7/site-packages/_emerge/Package.py", line 633, in use
    self._init_use()
  File "/usr/lib64/python2.7/site-packages/_emerge/Package.py", line 664, in _init_use
    use_str = self._get_pkgsettings()["PORTAGE_USE"]
  File "/usr/lib64/python2.7/site-packages/_emerge/Package.py", line 639, in _get_pkgsettings
    pkgsettings.setcpv(self)
  File "/usr/lib64/python2.7/site-packages/portage/package/ebuild/config.py", line 1381, in wrapper
    raise AssertionError('setcpv recursion detected')
AssertionError: setcpv recursion detected


Expected Results:  
Unwanted files deleted

I can sync, emerge new programs, and run eclean. But not "emerge --depclean".
Comment 1 Paul Monsour 2017-02-01 03:02:20 UTC
Output of "emerge --info"

Portage 2.3.3 (python 2.7.12-final-0,
default/linux/amd64/13.0/desktop/plasma/systemd, gcc-5.4.0,
glibc-2.23-r3, 4.9.6-gentoo-oc x86_64)
=================================================================
System uname:
Linux-4.9.6-gentoo-oc-x86_64-AMD_FX-tm-6300_Six-Core_Processor-with-gentoo-2.3
qKiB Mem: 16334208 total, 9489444 free KiB Swap: 0 total, 0 free
Timestamp of repository gentoo: Tue, 31 Jan 2017 13:30:01 +0000 sh
bash 4.4_p11 ld GNU ld (Gentoo 2.27 p1.0) 2.27 app-shells/bash:
4.4_p11::gentoo dev-lang/perl: 5.24.1_rc4::gentoo dev-lang/python:
2.7.12::gentoo, 3.4.5::gentoo dev-util/cmake: 3.7.2::gentoo
dev-util/pkgconfig: 0.29.1::gentoo sys-apps/baselayout: 2.3::gentoo
sys-apps/openrc: 0.23.2::gentoo sys-apps/sandbox: 2.10-r3::gentoo
sys-devel/autoconf: 2.13::gentoo, 2.69-r2::gentoo sys-devel/automake:
1.13.4-r1::gentoo, 1.14.1-r1::gentoo, 1.15-r2::gentoo
sys-devel/binutils: 2.27::gentoo sys-devel/gcc: 4.9.3::gentoo,
5.4.0-r2::gentoo sys-devel/gcc-config: 1.8-r1::gentoo
sys-devel/libtool: 2.4.6-r2::gentoo sys-devel/make: 4.2.1::gentoo
sys-kernel/linux-headers: 4.9::gentoo (virtual/os-headers)
sys-libs/glibc: 2.23-r3::gentoo Repositories:

gentoo location: /usr/portage sync-type: rsync sync-uri:
    rsync://rsync.gentoo.org/gentoo-portage priority: -1000

ACCEPT_KEYWORDS="amd64 ~amd64" ACCEPT_LICENSE="* -@EULA FraunhoferFDK"
CBUILD="x86_64-pc-linux-gnu" CFLAGS="-march=bdver1 -mprefer-avx128
-mvzeroupper -O2 -pipe" CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /etc/entropy /usr/lib64/fax /usr/share/config
/usr/share/gnupg/qualified.txt /usr/share/themes/oxygen-gtk/gtk-2.0
/var/spool/fax/etc" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf
/etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf
/etc/gentoo-release /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="-march=bdver1
-mprefer-avx128 -mvzeroupper -O2 -pipe"
DISTDIR="/usr/portage/distfiles" FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs 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 userpriv
usersandbox usersync xattr" FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org" LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed" MAKEOPTS="-j7"
PKGDIR="/usr/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 --exclude=/.git" PORTAGE_TMPDIR="/var/tmp"
USE="3dnowprefetch X a52 aac abm acl acpi aes alsa alsa-plugin amd64
aperfmperf apic arat avx berkdb bindist bluetooth bluray bmi1 branding
bzip2 cairo cdda cdr clflush cli cmov cmp_legacy constant_tsc cpb
cr8_legacy cracklib crypt cups cx16 cx8 cxx dbus de declarative
decodeassists dhclient dri dts dvd dvdr efi emboss encode exif extapic
extd_apicid f16c fam ffmpeg firefox flac flushbyasid fma fma4 fortran
fpu fxsr fxsr_opt gdbm gif glamor gphoto2 gpm gtk gudev ht hw_pstate
hwdb ibs iconv icu id3tag ipv6 jack jpeg kde kipi lahf_lm lbrv lcms
ldap libnotify lm lwp mad mca mce misalignsse mng modules monitor mp3
mp4 mpeg msr mtrr multilib ncurses nls nodeid_msr nonstop_tsc nopl npt
nptl nrip_save nx ogg opengl openmp osvw pae pam pango pat pausefilter
pclmulqdq pcre pdf pdpe1gb perfctr_core perfctr_nb pfthreshold pge
phonon plasma png pni policykit popcnt ppds pse pse36 pulseaudio qml
qt3support qt4 qt5 rdtscp readline rep_good scanner sdl seccomp
semantic-desktop sep session skinit spell sse sse2 sse4_1 sse4_2 sse4a
ssl ssse3 startup-notification svg svm svm_lock syscall systemd
tagfile tbm tce tcpd tiff topoext truetype tsc tsc_scale udev udisks
unicode upower usb v4l2 vmcb_clean vme vorbis wdt widgets wxwidgets
x264 xattr xcb xcomposite xft xinerama xml xop xsave xscreensaver xv
xvid zlib" ABI_X86="64 32" ALSA_CARDS="ali5451 als4000 atiixp
atiixp-modem bt87x ca0106 cmipci 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="df interface irq load memory rrdtool swap syslog"
CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc"
GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt
gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle
oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip
tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64 pc"
INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz
cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text"
LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer"
LINGUAS="en" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6"
PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4"
RUBY_TARGETS="ruby21" SANE_BACKENDS="epkowa" USERLAND="GNU"
VIDEO_CARDS="radeon" 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: CC,
CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL,
PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS,
PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 2 Paul Monsour 2017-02-01 03:06:43 UTC
Created attachment 462044 [details]
Output from running "emerge --depclean"

"emerge --depclean" run after running "emerge --update --newuse --deep @world"
Comment 3 Zac Medico gentoo-dev 2017-02-01 03:37:54 UTC
It seems that you have an USE-atom (like foo/bar[baz]) in /etc/portage/package.use, so you should try to find that and remove the [baz] part.


We should fix the UseManager class to detect USE-atoms and warn about them here:

    self._pusedict = self._parse_user_files_to_extatomdict("package.use", abs_user_config, user_config)
Comment 4 Paul Monsour 2017-02-01 04:23:57 UTC
(In reply to Zac Medico from comment #3)
> It seems that you have an USE-atom (like foo/bar[baz]) in
> /etc/portage/package.use, so you should try to find that and remove the
> [baz] part.
> 
> 
> We should fix the UseManager class to detect USE-atoms and warn about them
> here:
> 
>     self._pusedict = self._parse_user_files_to_extatomdict("package.use",
> abs_user_config, user_config)

Bingo! There was a file "universal" dated today that had loads of files and loads of USE flags. Ended up removing that file, and voila! Depclean is hard at work as I type. Thank you, Zac!
Comment 5 Zac Medico gentoo-dev 2017-02-01 16:36:38 UTC
(In reply to Zac Medico from comment #3)
> We should fix the UseManager class to detect USE-atoms and warn about them
> here:
> 
>     self._pusedict = self._parse_user_files_to_extatomdict("package.use",
> abs_user_config, user_config)

It looks like we should add an allow_use parameter to the grabdict_package function, so that it can report the path(s) of the file(s) containing the invalid atom(s). Since package.use can be a directory, we could have multiple files to report.

(In reply to Paul Monsour from comment #4)
> Bingo! There was a file "universal" dated today that had loads of files and
> loads of USE flags. Ended up removing that file, and voila! Depclean is hard
> at work as I type. Thank you, Zac!

You're welcome, thanks for reporting!
Comment 6 Zac Medico gentoo-dev 2017-04-21 23:24:46 UTC
*** Bug 616234 has been marked as a duplicate of this bug. ***
Comment 7 D. C. Sessions 2017-11-19 17:21:17 UTC
Having just spent too much time tracking down the sources of this error on an "emerge -up world" might I suggest that this (and perhaps others) fatal exception be a bit more verbose?  As in, at least naming the ebuild that invoked it?
Comment 8 Larry the Git Cow gentoo-dev 2017-11-21 00:14:22 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=128c55ed57eea3f02b860a14a7e4f8cae109089a

commit 128c55ed57eea3f02b860a14a7e4f8cae109089a
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2017-11-21 00:01:40 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2017-11-21 00:11:48 +0000

    UseManager: reject atoms with USE flags (bug 607872)
    
    Reject atoms with USE flags in package.* files since
    they trigger infinite recursion in config.setcpv().
    
    Bug: https://bugs.gentoo.org/607872

 pym/portage/package/ebuild/_config/UseManager.py | 5 +++--
 pym/portage/util/__init__.py                     | 6 +++++-
 2 files changed, 8 insertions(+), 3 deletions(-)}
Comment 9 Larry the Git Cow gentoo-dev 2017-11-21 01:34:22 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=8267445cf2f8697f12f1424ecdb4f495dc19f27f

commit 8267445cf2f8697f12f1424ecdb4f495dc19f27f
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2017-11-21 00:45:18 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2017-11-21 01:31:21 +0000

    binarytree.populate: avoid lock when possible (bug 607872)
    
    In order to avoid unecessary lock contention, do not lock
    the Packages file unless it needs to be updated. This is
    useful when PKGDIR is shared via NFS.
    
    Bug: https://bugs.gentoo.org/607872

 pym/portage/dbapi/bintree.py | 80 +++++++++++++++++++++++++-------------------
 1 file changed, 46 insertions(+), 34 deletions(-)}
Comment 10 Zac Medico gentoo-dev 2017-11-21 01:45:52 UTC
(In reply to Larry the Git Cow from comment #9)
> The bug has been referenced in the following commit(s):
> 
> https://gitweb.gentoo.org/proj/portage.git/commit/
> ?id=8267445cf2f8697f12f1424ecdb4f495dc19f27f

Oops, that was intended to reference bug 636798.