Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 928513 - sys-apps/portage does not terminate on first ^C but needs a second one
Summary: sys-apps/portage does not terminate on first ^C but needs a second one
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 910332
  Show dependency tree
 
Reported: 2024-04-03 13:55 UTC by Georgi
Modified: 2024-11-12 19:06 UTC (History)
3 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 Georgi 2024-04-03 13:55:13 UTC
After emerge process have started, sometimes if you press CTRL+C to terminate, it looks like it terminates something else and continues until a second CTRL-C is pressed. There are two ^C, one is alone in a line and the second is on the last configure line. I think this happens most often during things like pre-merge checks and waiting for files being downloaded, but I'm not positive about that. Here's the emerge output:


```
# emerge -DuUav @world neovide

These are the packages that would be merged, in order:

Calculating dependencies... done!
Dependency resolution took 28.04 s (backtrack: 1/20).

[ebuild     U  ] x11-libs/libXdmcp-1.1.5::gentoo [1.1.4-r2::gentoo] USE="-doc" ABI_X86="32 (64) (-x32)" 291 KiB
[ebuild     U  ] x11-libs/libxcb-1.16.1:0/1.12::gentoo [1.16-r1:0/1.12::gentoo] USE="xkb -doc (-selinux) -test" ABI_X86="32 (64) (-x32)" 445 KiB
[ebuild     U  ] dev-libs/nss-3.99::gentoo [3.98::gentoo] USE="utils -cacert -test" ABI_X86="(64) -32 (-x32)" CPU_FLAGS_X86="avx2 sse3" 74,956 KiB
[ebuild     U  ] x11-libs/libfontenc-1.1.8::gentoo [1.1.7::gentoo] 268 KiB
[ebuild  N     ] dev-build/gn-0.2143::gentoo  0 KiB
[ebuild     U  ] x11-apps/mkfontscale-1.2.3::gentoo [1.2.2::gentoo] 143 KiB
[ebuild     U  ] x11-apps/xauth-1.1.3::gentoo [1.1.2::gentoo] 156 KiB
[ebuild     U  ] www-plugins/chrome-binary-plugins-123.0.6312.105:stable::gentoo [123.0.6312.86:stable::gentoo] 104,717 KiB
[ebuild     U  ] dev-lua/mpack-1.0.12::gentoo [1.0.11::gentoo] USE="-test" LUA_TARGETS="lua5-1 luajit -lua5-3 -lua5-4" 17 KiB
[ebuild     U  ] x11-libs/pixman-0.43.4::gentoo [0.43.2::gentoo] USE="(-loongson2f) -static-libs -test" ABI_X86="32 (64) (-x32)" CPU_FLAGS_X86="mmxext sse2 ssse3" 622 KiB
[ebuild     U  ] media-fonts/encodings-1.1.0::gentoo [1.0.7::gentoo] 292 KiB
[ebuild     U  ] media-libs/lsp-plugins-1.2.14::gentoo [1.2.3-r1::gentoo] USE="X lv2 -doc -jack -ladspa -test -vst" 45,387 KiB
[ebuild     U  ] media-libs/mesa-24.0.4::gentoo [23.3.6::gentoo] USE="X gles2 llvm (opengl%*) proprietary-codecs vaapi vdpau vulkan wayland zstd -d3d9 -debug -gles1 -lm-sensors -opencl -osmesa (-selinux) -test -unwind -valgrind -vulkan-overlay -xa (-zink)" ABI_X86="32 (64) (-x32)" CPU_FLAGS_X86="sse2" LLVM_SLOT="17%* -15% -16%" VIDEO_CARDS="radeonsi -d3d12 (-freedreno) -intel -lavapipe (-lima) -nouveau (-panfrost) -r300 -r600 -radeon (-v3d) (-vc4) -virgl (-vivante) -vmware" 19,588 KiB
[ebuild     U  ] dev-python/pillow-10.3.0::gentoo [10.2.0-r1::gentoo] USE="jpeg lcms tiff truetype webp xcb zlib -debug -examples -imagequant -jpeg2k -test -tk" PYTHON_TARGETS="python3_11 (-pypy3) -python3_10 -python3_12" 45,544 KiB
[ebuild  N     ] dev-util/bindgen-0.68.1::gentoo  USE="-debug" ABI_X86="(64) -32 (-x32)" 3,396 KiB
[ebuild  N    ~] app-editors/neovide-0.12.2::guru  USE="-debug" 119,464 KiB
[ebuild     U  ] www-client/google-chrome-123.0.6312.105::gentoo [123.0.6312.86::gentoo] USE="-qt5 -qt6 (-selinux)" L10N="bg -af -am -ar -bn -ca -cs -da -de -el -en-GB -es -es-419 -et -fa -fi -fil -fr -gu -he -hi -hr -hu -id -it -ja -kn -ko -lt -lv -ml -mr -ms -nb -nl -pl -pt-BR -pt-PT -ro -ru -sk -sl -sr -sv -sw -ta -te -th -tr -uk -ur -vi -zh-CN -zh-TW" 0 KiB
[ebuild  r  U  ] dev-qt/qtbase-6.6.3:6/6.6.3::gentoo [6.6.2-r1:6/6.6.2::gentoo] USE="X concurrent cups dbus gtk gui icu libinput libproxy network nls opengl sql sqlite ssl udev vulkan wayland widgets xml zstd -accessibility -brotli -eglfs -evdev -gles2-only -gssapi -mysql -oci8 -odbc -postgres -sctp -test -tslib" 47,642 KiB
[ebuild     U  ] dev-qt/qtwayland-6.6.3:6/6.6.3::gentoo [6.6.2-r1:6/6.6.2::gentoo] USE="qml vulkan -accessibility -compositor -test" 1,094 KiB
[ebuild     U  ] dev-qt/qttools-6.6.3:6/6.6.3::gentoo [6.6.2:6/6.6.2::gentoo] USE="assistant linguist opengl qdbus vulkan widgets zstd -clang -designer -distancefieldgenerator -gles2-only -pixeltool -qdoc -qml -qtattributionsscanner -qtdiag -qtplugininfo -test" LLVM_SLOT="17 -15 -16 (-18)" 8,395 KiB
[ebuild     U  ] dev-qt/qttranslations-6.6.3:6/6.6.3::gentoo [6.6.2:6/6.6.2::gentoo] 1,438 KiB
[ebuild     U  ] dev-qt/qtsvg-6.6.3:6/6.6.3::gentoo [6.6.2:6/6.6.2::gentoo] USE="-test" 1,605 KiB
[ebuild     U  ] dev-qt/qtconnectivity-6.6.3:6/6.6.3::gentoo [6.6.2:6/6.6.2::gentoo] USE="bluetooth -nfc -smartcard -test" 1,037 KiB
[ebuild     U  ] dev-qt/qtshadertools-6.6.3:6/6.6.3::gentoo [6.6.2:6/6.6.2::gentoo] USE="-test" 1,030 KiB
[ebuild     U  ] dev-qt/qtimageformats-6.6.3:6/6.6.3::gentoo [6.6.2:6/6.6.2::gentoo] USE="mng -test" 1,919 KiB
[ebuild     U  ] dev-qt/qtdeclarative-6.6.3:6/6.6.3::gentoo [6.6.2-r1:6/6.6.2::gentoo] USE="opengl sql vulkan widgets -accessibility -test" 33,569 KiB
[ebuild  rR    ] gui-apps/qt6ct-0.9::gentoo  0 KiB
[ebuild     U  ] dev-qt/qtwebchannel-6.6.3:6/6.6.3::gentoo [6.6.2:6/6.6.2::gentoo] USE="qml -test" 202 KiB
[ebuild  rR    ] dev-python/PyQt6-6.6.1::gentoo  USE="bluetooth dbus gui network opengl printsupport qml quick sql ssl svg webchannel widgets xml -debug -designer -examples -gles2-only -help -multimedia -nfc -pdfium -positioning -quick3d -sensors -serialport -spatialaudio -speech -testlib -websockets" PYTHON_TARGETS="python3_11 -python3_10 -python3_12" 0 KiB
[ebuild     U  ] dev-qt/qtwebengine-6.6.3:6/6.6.3::gentoo [6.6.2:6/6.6.2::gentoo] USE="alsa bindist jumbo-build opengl pulseaudio qml screencast system-icu vulkan widgets -accessibility% -custom-cflags -designer -geolocation -kerberos -pdfium -test -vaapi" 411,217 KiB
[ebuild  rR    ] app-text/calibre-7.5.0::gentoo  USE="font-subsetting system-mathjax udisks -ios -speech -test -unrar -verify-sig" PYTHON_SINGLE_TARGET="python3_11 -python3_10" 0 KiB

Total: 31 packages (25 upgrades, 3 new, 3 reinstalls), Size of downloads: 924,424 KiB

The following packages are causing rebuilds:

  (dev-qt/qtbase-6.6.3:6/6.6.3::gentoo, ebuild scheduled for merge) causes rebuilds for:
    (gui-apps/qt6ct-0.9:0/0::gentoo, ebuild scheduled for merge)
    (dev-python/PyQt6-6.6.1:0/0::gentoo, ebuild scheduled for merge)
    (app-text/calibre-7.5.0:0/0::gentoo, ebuild scheduled for merge)

Would you like to merge these packages? [Yes/No] 

>>> Verifying ebuild manifests

>>> Running pre-merge checks for x11-libs/pixman-0.43.4

>>> Running pre-merge checks for media-libs/mesa-24.0.4

>>> Running pre-merge checks for www-client/google-chrome-123.0.6312.105

>>> Running pre-merge checks for dev-qt/qtwebengine-6.6.3
 * Checking for at least 32 GiB RAM ...
 * Amount of main memory is insufficient, but amount
 * of main memory combined with swap is sufficient.
 * Build process may make computer very slow!                                                                                                                                               [ ok ]
 * Checking for at least 7 GiB disk space at "/var/tmp/portage/dev-qt/qtwebengine-6.6.3/temp" ...                                                                                           [ ok ]
 * Checking for at least 220 MiB disk space at "/usr" ...                                                                                                                                   [ ok ]

>>> Emerging (1 of 31) x11-libs/libXdmcp-1.1.5::gentoo
 * Fetching files in the background.
 * To view fetch progress, run in another terminal:
 * tail -f /var/log/emerge-fetch.log
^C

Exiting on signal 2
 * libXdmcp-1.1.5.tar.xz BLAKE2B SHA512 size ;-) ...                                                                                                                                        [ ok ]
>>> Unpacking source...
>>> Unpacking libXdmcp-1.1.5.tar.xz to /var/tmp/portage/x11-libs/libXdmcp-1.1.5/work
>>> Source unpacked in /var/tmp/portage/x11-libs/libXdmcp-1.1.5/work
>>> Preparing source in /var/tmp/portage/x11-libs/libXdmcp-1.1.5/work/libXdmcp-1.1.5 ...
 * Running elibtoolize in: libXdmcp-1.1.5/
 *   Applying portage/1.2.0 patch ...
 *   Applying sed/1.5.6 patch ...
 *   Applying as-needed/2.4.3 patch ...
 *   Applying werror/2.4.7 patch ...
 *   Applying cxx-pthread/2.4.6 patch ...
 *   Applying color-record/2.4.7 patch ...
 *   Applying ppc64le/2.4.4 patch ...
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/x11-libs/libXdmcp-1.1.5/work/libXdmcp-1.1.5 ...
 * abi_x86_32.x86: running multilib-minimal_abi_src_configure
 * econf: updating libXdmcp-1.1.5/config.sub with /usr/share/gnuconfig/config.sub
 * econf: updating libXdmcp-1.1.5/config.guess with /usr/share/gnuconfig/config.guess
/var/tmp/portage/x11-libs/libXdmcp-1.1.5/work/libXdmcp-1.1.5/configure --prefix=/usr --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --datarootdir=/usr/share --disable-dependency-tracking --disable-silent-rules --disable-static --docdir=/usr/share/doc/libXdmcp-1.1.5 --htmldir=/usr/share/doc/libXdmcp-1.1.5/html --with-sysroot=/ --libdir=/usr/lib --disable-dependency-tracking --disable-selective-werror --disable-static --disable-docs --without-xmlto --without-fop
checking for i686-pc-linux-gnu-gcc... x86_64-pc-linux-gnu-gcc -m32 -mfpmath=sse
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether x86_64-pc-linux-gnu-gcc -m32 -mfpmath=sse accepts -g... yes
checking for x86_64-pc-linux-gnu-gcc -m32 -mfpmath=sse option to enable C11 features... none needed
checking whether x86_64-pc-linux-gnu-gcc -m32 -mfpmath=sse understands -c and -o together... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for wchar.h... yes
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether _XOPEN_SOURCE should be defined... ^Csandbox:stop  caught signal 2 in pid 4
 * The ebuild phase 'configure' has exited unexpectedly. This type of
 * behavior is known to be triggered by things such as failed variable
 * assignments (bug #190128) or bad substitution errors (bug #200313).
 * Normally, before exiting, bash should have displayed an error message
 * above. If bash did not produce an error message above, it's possible
 * that the ebuild has called `exit` when it should have called `die`
 * instead. This behavior may also be triggered by a corrupt bash binary or
 * a hardware problem such as memory or cpu malfunction. If the problem is
 * not reproducible or it appears to occur randomly, then it is likely to
 * be triggered by a hardware problem. If you suspect a hardware problem
 * then you should try some basic hardware diagnostics such as memtest.
 * Please do not report this as a bug unless it is consistently
 * reproducible and you are sure that your bash binary and hardware are
 * functioning properly.
```


Reproducible: Sometimes

Steps to Reproduce:
I haven't found a way to reliably reproduce it so far, nor I have noticed a pattern.
Comment 1 Georgi 2024-04-03 14:01:04 UTC
I forgot to add, this is x11-terms/gnome-terminal-3.50.1 under Gnome 45/Wayland
Comment 2 Georgi 2024-07-06 16:55:44 UTC
And another instance of that which made an impression on me it happens only if CTRL+C is pressed at a specific moment, either output of information to the console or while calculating dependencies:

```
emerge -ca --exclude "mpv mplayer gentoo-sources"

 * Always study the list of packages to be cleaned for any obvious
 * mistakes. Packages that are part of the world set will always
 * be kept.  They can be manually added to this set with
 * `emerge --noreplace <atom>`.  Packages that are listed in
 * package.provided (see portage(5)) will be removed by
 * depclean, even if they are part of the world set.
 * 
 * As a safety measure, depclean will not remove any packages
 * unless *all* required dependencies have been resolved.  As a
 * consequence of this, it often becomes necessary to run 
 * `emerge --update --newuse --deep @world` prior to depclean.

Calculating dependencies... done!
^CException ignored in: <function WeakSet.__init__.<locals>._remove at 0x7f0b3b723560>
Traceback (most recent call last):
  File "/usr/lib/python3.12/_weakrefset.py", line 39, in _remove
    def _remove(item, selfref=ref(self)):

KeyboardInterrupt: 
>>> Calculating removal order...
```

It continues with outputting the packages and asking me if I want to continue.

Best Regards,
Georgi
Comment 3 Zac Medico gentoo-dev 2024-07-06 18:27:11 UTC
(In reply to Georgi from comment #2)
> And another instance of that which made an impression on me it happens only
> if CTRL+C is pressed at a specific moment, either output of information to
> the console or while calculating dependencies:

It might be fragile around this spot where Scheduler overrides signal handlers during the call to self._merge() (it loops here if --keep-going is enabled):

> while True:
>     received_signal = []
> 
>     def sighandler(signum, frame):
>         signal.signal(signal.SIGINT, signal.SIG_IGN)
>         signal.signal(signal.SIGTERM, signal.SIG_IGN)
>         portage.util.writemsg(f"\n\nExiting on signal {signum}\n")
>         self.terminate()
>         received_signal.append(128 + signum)
> 
>     earlier_sigint_handler = signal.signal(signal.SIGINT, sighandler)
>     earlier_sigterm_handler = signal.signal(signal.SIGTERM, sighandler)
>     earlier_sigcont_handler = signal.signal(
>         signal.SIGCONT, self._sigcont_handler
>     )
>     signal.siginterrupt(signal.SIGCONT, False)
> 
>     try:
>         rval = self._merge()
>     finally:
>         # Restore previous handlers
>         if earlier_sigint_handler is not None:
>             signal.signal(signal.SIGINT, earlier_sigint_handler)
>         else:
>             signal.signal(signal.SIGINT, signal.SIG_DFL)
>         if earlier_sigterm_handler is not None:
>             signal.signal(signal.SIGTERM, earlier_sigterm_handler)
>         else:
>             signal.signal(signal.SIGTERM, signal.SIG_DFL)
>         if earlier_sigcont_handler is not None:
>             signal.signal(signal.SIGCONT, earlier_sigcont_handler)
>         else:
>             signal.signal(signal.SIGCONT, signal.SIG_DFL)
Comment 4 Georgi 2024-10-07 20:34:35 UTC
A bit more logs of a slightly different situation:

```
>>> Completed (38 of 59) dev-ruby/rbs-3.5.3::gentoo
>>> Emerging (40 of 59) dev-ruby/rexml-3.3.7::gentoo
>>> Emerging (41 of 59) net-p2p/transmission-4.0.6-r5::gentoo
>>> Emerging (42 of 59) net-im/signal-desktop-bin-7.27.0::gentoo
>>> Jobs: 39 of 59 complete, 1 running              Load avg: 4.41, 3.33, 2.10^C

Exiting on signal 2
>>> Installing (40 of 59) dev-ruby/rexml-3.3.7::gentoo
^CException ignored in atexit callback: <function _exit_function at 0x7f3977da63e0>
Traceback (most recent call last):
  File "/usr/lib/python3.12/multiprocessing/util.py", line 360, in _exit_function
    p.join()
  File "/usr/lib/python3.12/multiprocessing/process.py", line 149, in join
    res = self._popen.wait(timeout)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/multiprocessing/popen_fork.py", line 43, in wait
    return self.poll(os.WNOHANG if timeout == 0.0 else 0)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/multiprocessing/popen_fork.py", line 27, in poll
    pid, sts = os.waitpid(self.pid, flag)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt: 
[ERROR] Task was destroyed but it is pending!
task: <Task pending name='Task-11800' coro=<PipeLogger._io_loop() done, defined at /usr/lib/python3.12/site-packages/portage/util/_async/PipeLogger.py:83> wait_for=<Future pending cb=[Task.task_wakeup()]> cb=[PipeLogger._io_loop_done()]>
[ERROR] Task was destroyed but it is pending!
task: <Task pending name='Task-11801' coro=<BuildLogger._main() done, defined at /usr/lib/python3.12/site-packages/portage/util/_async/BuildLogger.py:131> wait_for=<Future pending cb=[AsynchronousTask.async_wait.<locals>.<lambda>() at /usr/lib/python3.12/site-packages/_emerge/AsynchronousTask.py:49, Task.task_wakeup()]> cb=[BuildLogger._main_exit()]>
[ERROR] Task was destroyed but it is pending!
task: <Task pending name='Task-11802' coro=<PipeLogger._io_loop() done, defined at /usr/lib/python3.12/site-packages/portage/util/_async/PipeLogger.py:83> wait_for=<Future pending cb=[Task.task_wakeup()]> cb=[PipeLogger._io_loop_done()]>
[ERROR] Task was destroyed but it is pending!
task: <Task pending name='Task-11803' coro=<ForkProcess._main() done, defined at /usr/lib/python3.12/site-packages/portage/util/_async/ForkProcess.py:177> wait_for=<Future pending cb=[AsynchronousTask.async_wait.<locals>.<lambda>() at /usr/lib/python3.12/site-packages/_emerge/AsynchronousTask.py:49, Task.task_wakeup()]> cb=[SpawnProcess._main_exit()]>
```
Comment 5 Zac Medico gentoo-dev 2024-10-07 20:49:15 UTC
(In reply to Georgi from comment #4)
I think this KeyboardInterrupt suggests that we should override the SIGINT handler in subprocesses like MergeProcess.
Comment 6 Georgi 2024-11-12 19:06:12 UTC
Some more logs, this time a bit different:

```
# emerge -DuUvg @world && systemctl suspend

Local copy of remote index is up-to-date and will be used.

Local copy of remote index is up-to-date and will be used.

These are the packages that would be merged, in order:

Calculating dependencies \^CException ignored in: <function WeakSet.__init__.<locals>._remove at 0x7f917e752020>
Traceback (most recent call last):
  File "/usr/lib/python3.12/_weakrefset.py", line 39, in _remove
    def _remove(item, selfref=ref(self)):

KeyboardInterrupt: 
 \... done!
Dependency resolution took 23.07 s.



Exiting on signal 2

```

I hope those shed more light on the issue.