Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 917033 - sys-apps/portage-3.0.55 RuntimeError: can't fork at interpreter shutdown with python-3.12
Summary: sys-apps/portage-3.0.55 RuntimeError: can't fork at interpreter shutdown with...
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: 916977
Blocks:
  Show dependency tree
 
Reported: 2023-11-08 10:12 UTC by jy6x2b32pie9
Modified: 2024-02-22 15:31 UTC (History)
0 users

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 jy6x2b32pie9 2023-11-08 10:12:33 UTC
After successful merge of a package, with python-3.12 emerge reports an exception:

====================================
Error in portage.process.run_exitfuncs

  File "/usr/lib/python3.12/site-packages/portage/process.py", line 212, in run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python3.12/site-packages/_emerge/actions.py", line 3836, in emergeexit
    xtermTitleReset()
  File "/usr/lib/python3.12/site-packages/portage/output.py", line 320, in xtermTitleReset
    spawn(
  File "/usr/lib/python3.12/site-packages/portage/process.py", line 456, in spawn
    pid = os.fork()
          ^^^^^^^^^
can't fork at interpreter shutdown
====================================

Exception ignored in atexit callback: <function run_exitfuncs at 0x7f08f5aa1080>
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/portage/process.py", line 220, in run_exitfuncs
    raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
  File "/usr/lib/python3.12/site-packages/portage/process.py", line 212, in run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python3.12/site-packages/_emerge/actions.py", line 3836, in emergeexit
    xtermTitleReset()
  File "/usr/lib/python3.12/site-packages/portage/output.py", line 320, in xtermTitleReset
    spawn(
  File "/usr/lib/python3.12/site-packages/portage/process.py", line 456, in spawn
    pid = os.fork()
          ^^^^^^^^^
RuntimeError: can't fork at interpreter shutdown

With python-3.11 this exception does not occur.

This problem also occurs when running emerge --info

Reproducible: Always

Steps to Reproduce:
eselect python set python-3.12
emerge --info
Actual Results:  
No RuntimeException and possibly unclean shutdown


Portage 3.0.55 (python 3.12.0-final-0, default/linux/amd64/17.1/desktop/plasma, gcc-13, glibc-2.38-r7, 6.6.0-gentoo x86_64)
=================================================================
System uname: Linux-6.6.0-gentoo-x86_64-AMD_Ryzen_7_5700U_with_Radeon_Graphics-with-glibc2.38
KiB Mem:    15714184 total,   2887436 free
KiB Swap:   16777212 total,  13096444 free
Timestamp of repository gentoo: Wed, 08 Nov 2023 09:15:01 +0000
Head commit of repository gentoo: 6f485c7057649bf60f212a52a68bb7e68fd8095a
Timestamp of repository calculate: Wed, 08 Nov 2023 07:48:43 +0000
Head commit of repository calculate: c647bd334f0bf8b2e786c79eaed5941fde31966a

Timestamp of repository guru: Wed, 08 Nov 2023 07:48:47 +0000
Head commit of repository guru: 4a7476c6fdb4bb160912ddd9de44d6fe3b9395f6

Timestamp of repository steam-overlay: Tue, 07 Nov 2023 05:37:13 +0000
Head commit of repository steam-overlay: ff5e56891b292cb2f9c62b257f986919bd4cfb4d

sh bash 5.2_p15-r7
ld GNU ld (Gentoo 2.41 p2) 2.41.0
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p15-r7::gentoo
dev-java/java-config:      2.3.1-r1::gentoo
dev-lang/perl:             5.38.0-r1::gentoo
dev-lang/python:           3.11.6::gentoo, 3.12.0_p1::gentoo
dev-lang/rust-bin:         1.73.0::gentoo
dev-util/cmake:            3.27.7::gentoo
dev-util/meson:            1.2.3::gentoo
sys-apps/baselayout:       2.14::gentoo
sys-apps/openrc:           0.51::gentoo
sys-apps/sandbox:          2.38::gentoo
sys-devel/autoconf:        2.13-r8::gentoo, 2.71-r7::gentoo
sys-devel/automake:        1.16.5-r1::gentoo
sys-devel/binutils:        2.41-r2::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           17.0.4::gentoo
sys-devel/gcc:             13.2.1_p20231014::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/libtool:         2.4.7-r1::gentoo
sys-devel/lld:             17.0.4::gentoo
sys-devel/llvm:            16.0.6::gentoo, 17.0.4::gentoo
sys-devel/make:            4.4.1-r1::gentoo
sys-kernel/linux-headers:  6.6::gentoo (virtual/os-headers)
sys-libs/glibc:            2.38-r7::gentoo
Repositories:

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

calculate
    location: /var/db/repos/calculate
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/calculate.git
    masters: gentoo
    volatile: False

guru
    location: /var/db/repos/guru
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/guru.git
    masters: gentoo
    volatile: False

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

steam-overlay
    location: /var/db/repos/steam-overlay
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/steam-overlay.git
    masters: gentoo
    volatile: False

Installed sets: @fonts
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=native -ggdb"
CHOST="x86_64-pc-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/terminfo"
CXXFLAGS="-O2 -pipe -march=native -ggdb"
DISTDIR="/var/cache/distfiles"
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 -march=native -ggdb"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg-live compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -march=native -ggdb"
GENTOO_MIRRORS="https://ftp.heanet.ie/mirrors/gentoo.org/     https://mirror.yandex.ru/gentoo-distfiles/     https://mirror1.sox.rs/gentoo/"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LEX="flex"
LINGUAS="en ru en_US ru_RU"
MAKEOPTS="-j8"
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"
SHELL="/bin/bash"
USE="X a52 aac acl acpi activities alsa amd64 audit avahi bluetooth branding bzip2 cairo caps cdr cli crypt cups dbus declarative dri dri3 dts dvd dvdr elogind encode epub evdev exif flac flatpak fontconfig fortran gdbm gegl gif gpm graphite gtk gui iconv icu ipv6 jemalloc jpeg kde kdesu kwallet lcms libass libdrm libnotify libtirpc lto lz4 lzma lzo mad magic mime mng mp3 mp4 mpeg mtp multilib ncurses networkmanager nls nptl ogg opengl openmp openssl pam pango pcre pdf pipewire plasma png policykit ppds pulseaudio qml qt5 rar readline samba screencast sdl seccomp semantic-desktop sound spell split-usr ssl startup-notification svg test-rust tiff tpm truetype udev udisks uefi unicode upower usb vaapi vorbis vulkan wayland webp webrtc-aec widgets wifi wxwidgets x264 x265 xattr xcb xft xinerama xml xv xvid zlib zstd" ABI_X86="64" ADA_TARGET="gnat_2021" 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="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="synaptics libinput joystick evdev" KERNEL="linux" L10N="ru en en-US ru-RU ja" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" 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_12" RUBY_TARGETS="ruby32" VIDEO_CARDS="radeonsi amdgpu radeon r600" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS


====================================
Error in portage.process.run_exitfuncs

  File "/usr/lib/python3.12/site-packages/portage/process.py", line 212, in run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python3.12/site-packages/_emerge/actions.py", line 3836, in emergeexit
    xtermTitleReset()
  File "/usr/lib/python3.12/site-packages/portage/output.py", line 320, in xtermTitleReset
    spawn(
  File "/usr/lib/python3.12/site-packages/portage/process.py", line 456, in spawn
    pid = os.fork()
          ^^^^^^^^^
can't fork at interpreter shutdown
====================================

Exception ignored in atexit callback: <function run_exitfuncs at 0x7f2215935080>
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/portage/process.py", line 220, in run_exitfuncs
    raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
  File "/usr/lib/python3.12/site-packages/portage/process.py", line 212, in run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python3.12/site-packages/_emerge/actions.py", line 3836, in emergeexit
    xtermTitleReset()
  File "/usr/lib/python3.12/site-packages/portage/output.py", line 320, in xtermTitleReset
    spawn(
  File "/usr/lib/python3.12/site-packages/portage/process.py", line 456, in spawn
    pid = os.fork()
          ^^^^^^^^^
RuntimeError: can't fork at interpreter shutdown
Comment 1 Zac Medico gentoo-dev 2023-11-08 16:47:34 UTC
This only happens when the PROMPT_COMMAND variable is exported.
Comment 2 Zac Medico gentoo-dev 2023-11-08 16:55:24 UTC
Apparently os.system is allowed during system shutdown.
Comment 3 Larry the Git Cow gentoo-dev 2023-11-10 16:04:27 UTC
The bug has been referenced in the following commit(s):

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

commit cfb856419711784fce2c5d54781338729cb94287
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2023-11-10 05:34:53 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2023-11-10 05:47:15 +0000

    emerge: Use finally instead of atexit for xtermTitleReset
    
    The xtermTitleReset function will trigger a RuntimeError
    when called via an atexit hook in python 3.12, since it
    forks to run PROMPT_COMMAND. Avoid this problem by calling
    it in a finally block instead of atexit.
    
    Bug: https://bugs.gentoo.org/917033
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/_emerge/actions.py | 10 ----------
 lib/_emerge/main.py    | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)
Comment 4 jy6x2b32pie9 2023-11-10 19:03:22 UTC
Tried portage-9999 with commit.
Can't reproduce bug.
Fix appears to be working.

Thank you.
Comment 5 Larry the Git Cow gentoo-dev 2023-12-01 03:03:27 UTC
The bug has been closed via the following commit(s):

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

commit baec60737ddc370dcf77ce1c797ff187357c4b14
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-12-01 02:54:12 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-12-01 02:54:29 +0000

    sys-apps/portage: add 3.0.56
    
    Closes: https://bugs.gentoo.org/760893
    Closes: https://bugs.gentoo.org/917033
    Closes: https://bugs.gentoo.org/917259
    Closes: https://bugs.gentoo.org/917315
    Closes: https://bugs.gentoo.org/918515
    Closes: https://bugs.gentoo.org/918682
    Closes: https://bugs.gentoo.org/918683
    Closes: https://bugs.gentoo.org/916977
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-3.0.56.ebuild | 238 +++++++++++++++++++++++++++++++++
 2 files changed, 239 insertions(+)