Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 925333 - sys-apps/portage-3.0.62: -e @world gets interrupted
Summary: sys-apps/portage-3.0.62: -e @world gets interrupted
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on: 925214
Blocks:
  Show dependency tree
 
Reported: 2024-02-23 13:11 UTC by Sam James
Modified: 2024-03-05 13:23 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-02-23 13:11:00 UTC
I had this just now with a world rebuild:
```
$ emerge -ev @world
[...]
>>> Completed (515 of 2557) sys-devel/llvm-17.0.6::gentoo

>>> Emerging (516 of 2557) sys-devel/gcc-14.0.9999::gentoo
[ERROR] Exception in callback AsynchronousTask._exit_listener_cb(<bound method...ffff9b50e200>>)
handle: <Handle AsynchronousTask._exit_listener_cb(<bound method...ffff9b50e200>>)>
Traceback (most recent call last):
  File "/usr/lib/python3.11/asyncio/events.py", line 84, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/lib/python3.11/site-packages/_emerge/AsynchronousTask.py", line 209, in _exit_listener_cb
    listener(self)
  File "/usr/lib/python3.11/site-packages/_emerge/EbuildBuild.py", line 77, in _start_with_metadata
    (settings.configdict["pkg"]["SRC_URI"],) = aux_get_task.future.result()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/portage/dbapi/porttree.py", line 786, in async_aux_get
    raise AssertionError(
AssertionError: async_aux_get called from thread <_MainThread(MainThread, started 281473559502880)> with loop <_emerge.Scheduler.Scheduler._iface_class object at 0xffff8e3a8840>
Terminated
```

There's another issue w/ emerge --version too:
```
$ emerge --version
Portage 3.0.62 (python 3.11.8-final-0, default/linux/arm64/17.0/hardened, gcc-14, glibc-2.38-r11, 5.15.148-gentoo-dist aarch64)
[ERROR] Task was destroyed but it is pending!
task: <Task pending name='Task-4' coro=<ForkProcess._main() running at /usr/lib/python3.11/site-packages/portage/util/_async/ForkProcess.py:200> wait_for=<Future pending cb=[AsynchronousTask.async_wait.<locals>.<lambda>() at /usr/lib/python3.11/site-packages/_emerge/AsynchronousTask.py:49, Task.task_wakeup()]> cb=[SpawnProcess._main_exit()]>
```

--

# emerge --info
Portage 3.0.62 (python 3.11.8-final-0, default/linux/arm64/17.0/hardened, gcc-14, glibc-2.38-r11, 5.15.148-gentoo-dist aarch64)
=================================================================
System uname: Linux-5.15.148-gentoo-dist-aarch64-with-glibc2.38
KiB Mem:   262954136 total, 128329816 free
KiB Swap:    9767620 total,   8875716 free
Timestamp of repository gentoo: Fri, 23 Feb 2024 12:33:50 +0000
sh dash 0.5.12
ld GNU ld (Gentoo 2.42 p3) 2.42.0
ccache version 4.9.1 [disabled]
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p26::gentoo
dev-build/autoconf:        2.13-r8::gentoo, 2.69-r9::gentoo, 2.71-r7::gentoo, 2.72-r1::gentoo
dev-build/automake:        1.16.5-r2::gentoo
dev-build/cmake:           3.28.3::gentoo
dev-build/libtool:         2.4.7-r2::gentoo
dev-build/make:            4.4.1-r1::gentoo
dev-build/meson:           1.3.2::gentoo
dev-java/java-config:      2.3.3-r1::gentoo
dev-lang/perl:             5.38.2-r1::gentoo
dev-lang/python:           3.10.13_p3::gentoo, 3.11.8_p1::gentoo, 3.12.2_p1::gentoo
dev-lang/rust-bin:         1.75.0::gentoo
dev-util/ccache:           4.9.1::gentoo
sys-apps/baselayout:       2.14-r2::gentoo
sys-apps/sandbox:          2.38::gentoo
sys-apps/systemd:          255.3-r1::gentoo
sys-devel/binutils:        2.42-r1::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           15.0.7-r3::gentoo, 16.0.6::gentoo, 17.0.6::gentoo
sys-devel/gcc:             11.4.1_p20240215::gentoo, 12.3.1_p20240209::gentoo, 13.2.1_p20240210::gentoo, 14.0.9999::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/lld:             15.0.7::gentoo, 16.0.6::gentoo, 17.0.6::gentoo
sys-devel/llvm:            15.0.7-r3::gentoo, 16.0.6::gentoo, 17.0.6::gentoo
sys-kernel/linux-headers:  6.7::gentoo (virtual/os-headers)
sys-libs/glibc:            2.38-r11::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    volatile: False
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-jobs: 1
    sync-rsync-extra-opts: 
    sync-rsync-verify-metamanifest: yes

local
    location: /var/db/repos/local
    masters: gentoo
    volatile: False

Installed sets: @sam
ACCEPT_KEYWORDS="arm64 ~arm64"
ACCEPT_LICENSE="*"
CBUILD="aarch64-unknown-linux-gnu"
CFLAGS="-O2 -pipe -mcpu=native -fdiagnostics-color=always -ggdb3 -fno-vect-cost-model -U_FORTIFY_SOURCE -fno-hardened -fpermissive"
CHOST="aarch64-unknown-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
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/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -pipe -mcpu=native -fdiagnostics-color=always -ggdb3 -fno-vect-cost-model -U_FORTIFY_SOURCE -fno-hardened"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="--keep-going=y --complete-graph"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-O2 -pipe -mcpu=native -fdiagnostics-color=always -ggdb3 -fno-vect-cost-model -U_FORTIFY_SOURCE -fno-hardened"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live clean-logs compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles merge-wait multilib-strict news parallel-fetch pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms split-elog split-log splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -mcpu=native -fdiagnostics-color=always -ggdb3 -fno-vect-cost-model -U_FORTIFY_SOURCE -fno-hardened"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="C.UTF8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0"
LEX="flex"
PKGDIR="/var/cache/binpkgs"
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="X a52 aac accessibility acl acpi activities alsa arm64 bluetooth branding brotli bzip2 cairo cdda cdr cli colord crypt cups dbus declarative dot dri dts dvdr encode exif flac fortran gdbm gif gpm gtk gui hardened http http2 iconv icu ipv6 jadetex jpeg kde kwallet lcms libnotify libtirpc libxml2 lua lz4 lzma mad mng mp3 mp4 mpeg ncurses networkmanager nls ogg opengl openmp opus pam pango pcre pcre32 pdf perl pic pie pim pipewire plasma png policykit ppds pulseaudio python qml qt5 readline ruby screencast sdk sdl seccomp semantic-desktop snappy sound spell sql sqlite ssh ssl ssp startup-notification svg systemd test-rust tiff truetype udev udisks unicode upower usb vorbis vulkan wayland webchannel webengine webkit widgets wifi wireless wxwidgets x264 xattr xcb xft xml xtpax xv xvid zlib zstd" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_ARM="edsp vfp vfpv3 vfpv4 vfp-d32 aes sha1 sha2 crc32 v8" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 ntrip navcom oceanserver oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 tsip tripmate tnt ublox" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-1" POSTGRES_TARGETS="postgres15" PYTHON_SINGLE_TARGET="python3_11" PYTHON_TARGETS="python3_11 python3_10" RUBY_TARGETS="ruby31 ruby32" VIDEO_CARDS="fbdev dummy" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, MAKEOPTS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RANLIB, READELF, RUSTFLAGS, SHELL, SIZE, STRINGS, STRIP, YACC, YFLAGS

[ERROR] Task was destroyed but it is pending!
task: <Task pending name='Task-4' coro=<ForkProcess._main() running at /usr/lib/python3.11/site-packages/portage/util/_async/ForkProcess.py:200> wait_for=<Future pending cb=[AsynchronousTask.async_wait.<locals>.<lambda>() at /usr/lib/python3.11/site-packages/_emerge/AsynchronousTask.py:49, Task.task_wakeup()]> cb=[SpawnProcess._main_exit()]>
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-02-23 13:11:54 UTC
It might be that the first one is just noise from an emerge --sync while the -e is running, but it seems weird that it died on a live ebuild which is still in tree.
Comment 2 Zac Medico gentoo-dev 2024-02-23 16:36:17 UTC
(In reply to Sam James from comment #0)
> I had this just now with a world rebuild:
> ```
> $ emerge -ev @world
> [...]
> >>> Completed (515 of 2557) sys-devel/llvm-17.0.6::gentoo
> 
> >>> Emerging (516 of 2557) sys-devel/gcc-14.0.9999::gentoo
> [ERROR] Exception in callback AsynchronousTask._exit_listener_cb(<bound
> method...ffff9b50e200>>)
> handle: <Handle AsynchronousTask._exit_listener_cb(<bound
> method...ffff9b50e200>>)>
> Traceback (most recent call last):
>   File "/usr/lib/python3.11/asyncio/events.py", line 84, in _run
>     self._context.run(self._callback, *self._args)
>   File "/usr/lib/python3.11/site-packages/_emerge/AsynchronousTask.py", line
> 209, in _exit_listener_cb
>     listener(self)
>   File "/usr/lib/python3.11/site-packages/_emerge/EbuildBuild.py", line 77,
> in _start_with_metadata
>     (settings.configdict["pkg"]["SRC_URI"],) = aux_get_task.future.result()
>                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/usr/lib/python3.11/site-packages/portage/dbapi/porttree.py", line
> 786, in async_aux_get
>     raise AssertionError(
> AssertionError: async_aux_get called from thread <_MainThread(MainThread,
> started 281473559502880)> with loop
> <_emerge.Scheduler.Scheduler._iface_class object at 0xffff8e3a8840>
> Terminated
> ```

https://github.com/gentoo/portage/pull/1278 should fix this but I haven't tested it yet.


> There's another issue w/ emerge --version too:
> ```
> $ emerge --version
> Portage 3.0.62 (python 3.11.8-final-0, default/linux/arm64/17.0/hardened,
> gcc-14, glibc-2.38-r11, 5.15.148-gentoo-dist aarch64)
> [ERROR] Task was destroyed but it is pending!
> task: <Task pending name='Task-4' coro=<ForkProcess._main() running at
> /usr/lib/python3.11/site-packages/portage/util/_async/ForkProcess.py:200>
> wait_for=<Future pending cb=[AsynchronousTask.async_wait.<locals>.<lambda>()
> at /usr/lib/python3.11/site-packages/_emerge/AsynchronousTask.py:49,
> Task.task_wakeup()]> cb=[SpawnProcess._main_exit()]>

Hmm, that could be something like one of the stty spawns, so we really need to make it return a Future to wait for when the event loop is running:

commit f97e414ce980299acc962e357db24106d62e4c7c
Author: Zac Medico <zmedico@gentoo.org>
Date:   Sat Feb 3 22:12:00 2024 -0800

    set_term_size: Wait asynchronously if event loop is running
    
    When set_term_size is called from an asynchronous context, we
    can wait for the process to exit asynchronously. This will
    prevent a "RuntimeError: This event loop is already running"
    error in the future when synchronous spawn calls will need
    to run the event loop in order to wait for the spawned
    process(es).
    
    Bug: https://bugs.gentoo.org/923750
    Signed-off-by: Zac Medico <zmedico@gentoo.org>
Comment 3 Zac Medico gentoo-dev 2024-02-24 04:13:31 UTC
(In reply to Zac Medico from comment #2)
> > There's another issue w/ emerge --version too:
> > ```
> > $ emerge --version
> > Portage 3.0.62 (python 3.11.8-final-0, default/linux/arm64/17.0/hardened,
> > gcc-14, glibc-2.38-r11, 5.15.148-gentoo-dist aarch64)
> > [ERROR] Task was destroyed but it is pending!
> > task: <Task pending name='Task-4' coro=<ForkProcess._main() running at
> > /usr/lib/python3.11/site-packages/portage/util/_async/ForkProcess.py:200>
> > wait_for=<Future pending cb=[AsynchronousTask.async_wait.<locals>.<lambda>()
> > at /usr/lib/python3.11/site-packages/_emerge/AsynchronousTask.py:49,
> > Task.task_wakeup()]> cb=[SpawnProcess._main_exit()]>
> 
> Hmm, that could be something like one of the stty spawns, so we really need
> to make it return a Future to wait for when the event loop is running:
> 
> commit f97e414ce980299acc962e357db24106d62e4c7c
> Author: Zac Medico <zmedico@gentoo.org>
> Date:   Sat Feb 3 22:12:00 2024 -0800
> 
>     set_term_size: Wait asynchronously if event loop is running

Also, it might be possible for the ForkProcess instance used by _start_proc to trigger this (introduced in a69c1b853a47 for bug 916566), since _start_proc only returns the associated MultiprocessingProcess instance, so the ForkProcess instance can get garbage collected before its main coroutine exits.
Comment 4 Larry the Git Cow gentoo-dev 2024-02-24 20:03:06 UTC
The bug has been referenced in the following commit(s):

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

commit acb69a6f234bd412e95e76f5c1db1b1f5b8e1dc5
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2024-02-24 03:52:47 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2024-02-24 04:23:27 +0000

    SchedulerInterface/PollScheduler: Add _loop property
    
    This allows async_aux_get to easily verify the identity of
    the underlying loop so that this assertion will not fail:
    
    _start_with_metadata
        (settings.configdict["pkg"]["SRC_URI"],) = aux_get_task.future.result()
                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/portage/dbapi/porttree.py", line 786, in async_aux_get
        raise AssertionError(
    AssertionError: async_aux_get called from thread <_MainThread(MainThread, started 281473559502880)> with loop <_emerge.Scheduler.Scheduler._iface_class object at 0xffff8e3a8840>
    Terminated
    
    Fixes: 389bb304abf5 ("async_aux_get: Use EbuildMetadataPhase deallocate_config future")
    Bug: https://bugs.gentoo.org/925333
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/_emerge/PollScheduler.py                    | 9 ++++++++-
 lib/portage/dbapi/porttree.py                   | 2 +-
 lib/portage/tests/ebuild/test_doebuild_spawn.py | 3 ++-
 lib/portage/tests/ebuild/test_ipc_daemon.py     | 3 ++-
 lib/portage/util/_async/SchedulerInterface.py   | 9 ++++++++-
 5 files changed, 21 insertions(+), 5 deletions(-)
Comment 5 Zac Medico gentoo-dev 2024-02-25 05:31:52 UTC
(In reply to Zac Medico from comment #3)
> Also, it might be possible for the ForkProcess instance used by _start_proc
> to trigger this (introduced in a69c1b853a47 for bug 916566), since
> _start_proc only returns the associated MultiprocessingProcess instance, so
> the ForkProcess instance can get garbage collected before its main coroutine
> exits.

Let's follow up on this issue in bug 925456 (I now have a patch to test in https://github.com/gentoo/portage/pull/1284).
Comment 6 Larry the Git Cow gentoo-dev 2024-02-25 08:33:03 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6ad9d3103abc02f60d9e123ae21fa4a2e69b7e38

commit 6ad9d3103abc02f60d9e123ae21fa4a2e69b7e38
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-02-25 08:32:40 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-02-25 08:32:47 +0000

    sys-apps/portage: add 3.0.63
    
    Closes: https://bugs.gentoo.org/925214
    Closes: https://bugs.gentoo.org/651018
    Closes: https://bugs.gentoo.org/922935
    Closes: https://bugs.gentoo.org/925240
    Closes: https://bugs.gentoo.org/925311
    Closes: https://bugs.gentoo.org/925333
    Closes: https://bugs.gentoo.org/925350
    Closes: https://bugs.gentoo.org/925456
    Closes: https://bugs.gentoo.org/925460
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-3.0.63.ebuild | 246 +++++++++++++++++++++++++++++++++
 2 files changed, 247 insertions(+)