Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 656542 - =sys-apps/portage-2.3.40 - TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object
Summary: =sys-apps/portage-2.3.40 - TypeError: signal handler must be signal.SIG_IGN, ...
Status: CONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 910332
  Show dependency tree
 
Reported: 2018-05-26 01:09 UTC by Manuel Rüger (RETIRED)
Modified: 2023-07-14 10:35 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 Manuel Rüger (RETIRED) gentoo-dev 2018-05-26 01:09:14 UTC
Seeing this traceback, if there's an unclean build directory, that the current user has no access to:

Appending /home/mruger/repos/gentoo to PORTDIR_OVERLAY...
Forcing test.
>>> Creating Manifest for /home/mruger/repos/gentoo/app-admin/keepass
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/image/usr/share/keepass/XSL/KDBX_PasswordsOnly_TXT.xsl': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/image/usr/share/keepass/XSL/KDBX_Tabular_HTML.xsl': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/image/usr/share/keepass/XSL/KDBX_Common.xsl': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/image/usr/share/keepass/XSL/KDBX_DetailsFull_HTML.xsl': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/image/usr/share/keepass/XSL/KDBX_DetailsLight_HTML.xsl': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/image/usr/share/icons/gnome/256x256/mimetypes/application-x-keepass2.png': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/image/usr/share/icons/hicolor/256x256/apps/keepass.png': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/image/usr/share/applications/keepass-keepass.desktop': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/image/usr/share/mime/packages/keepass.xml': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/image/usr/bin/keepass': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/image/usr/lib64/keepass/KeePass.exe': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/image/usr/lib64/keepass/KeePass.config.xml': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/image/usr/lib64/keepass/KeePass.exe.config': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/homedir': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/.installed': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/temp/build.log': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/temp/keepass-keepass.desktop': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/temp/environment': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/temp/logging/install': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/temp/logging/prepare': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/temp/.portage_user_patches_applied': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/temp/eclass-debug.log': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/temp/tmp.VNBT5W6fsf': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/.pretended': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/.setuped': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/.unpacked': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/.prepared': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/.configured': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/.compiled': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/.tested': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/.ipc_in': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/.ipc_out': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/repository': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/PF': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/CBUILD': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/FEATURES': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/CATEGORY': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/DEPEND': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/INHERITED': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/LICENSE': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/IUSE': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/keepass-2.39.1.ebuild': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/SLOT': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/environment.bz2': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/DEFINED_PHASES': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/KEYWORDS': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/DESCRIPTION': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/CHOST': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/IUSE_EFFECTIVE': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/HOMEPAGE': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/BUILD_TIME': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/CFLAGS': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/CXXFLAGS': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/LDFLAGS': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/USE': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/RDEPEND': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/SIZE': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/build-info/EAPI': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/work': Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/files': Permission denied
find: ‘/var/tmp/portage/app-admin/keepass-2.39.1/work’: Permission denied
rm: cannot remove '/var/tmp/portage/app-admin/keepass-2.39.1/distdir/KeePass-2.39.1-Source.zip': Permission denied
>>> Checking KeePass-2.39.1-Source.zip's mtime...
>>> WORKDIR is up-to-date, keeping...
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.5/ebuild", line 352, in <module>
    vartree=portage.db[portage.root]['vartree'])
  File "/usr/lib64/python3.5/site-packages/portage/package/ebuild/doebuild.py", line 976, in doebuild
    mystatus = prepare_build_dirs(myroot, mysettings, cleanup)
  File "/usr/lib64/python3.5/site-packages/portage/package/ebuild/prepare_build_dirs.py", line 43, in prepare_build_dirs
    shutil.rmtree(clean_dir)
  File "/usr/lib64/python3.5/site-packages/portage/__init__.py", line 250, in __call__
    rval = self._func(*wrapped_args, **wrapped_kwargs)
  File "/usr/lib64/python3.5/shutil.py", line 484, in rmtree
    onerror(os.rmdir, path, sys.exc_info())
  File "/usr/lib64/python3.5/shutil.py", line 482, in rmtree
    os.rmdir(path)
PermissionError: [Errno 13] Permission denied: '/var/tmp/portage/app-admin/keepass-2.39.1/homedir'
Exception ignored in: <bound method BaseEventLoop.__del__ of <_UnixSelectorEventLoop running=False closed=True debug=False>>
Traceback (most recent call last):
  File "/usr/lib64/python3.5/asyncio/base_events.py", line 511, in __del__
  File "/usr/lib64/python3.5/asyncio/unix_events.py", line 65, in close
  File "/usr/lib64/python3.5/asyncio/unix_events.py", line 146, in remove_signal_handler
  File "/usr/lib64/python3.5/signal.py", line 47, in signal
TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object
Comment 1 Zac Medico gentoo-dev 2018-05-26 05:38:27 UTC
If we fix prepare_build_dirs to wrap the PermissionError with portage.exception.PermissionDenied, then it will be handled without showing the traceback(s) in bin/ebuild here::

>     except PermissionDenied as e:
>         portage.writemsg("!!! Permission Denied: %s\n" % (e,), noiselevel=-1)
>         a = 1

We can reuse the portage.util.install_mask._raise_exc function to wrap exceptions like this (includes support for PEP 3134 exception chaining).

The "TypeError: signal handler" exception message is really just noise that is normally suppressed the asyncio event loop is cleanly closed. If we use try/finally to close the event loop, then it will close cleanly even in the event of an unexpected exception like the PermissionError.
Comment 2 Larry the Git Cow gentoo-dev 2018-05-26 06:09:53 UTC
The bug has been referenced in the following commit(s):

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

commit cd44fea4c8c8154fee74bcc37529c0d5c2e9d789
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2018-05-26 05:46:36 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2018-05-26 06:07:55 +0000

    prepare_build_dirs: convert PermissionError to PermissionDenied (bug 656542)
    
    This supresses display of a big PermissionError traceback for
    bin/ebuild, like in https://bugs.gentoo.org/656542#c0, and also
    suppresses additional messages that may occur when the unhandled
    PermissionError prevents bin/ebuild from cleanly closing the asyncio
    event loop.
    
    Bug: https://bugs.gentoo.org/656542

 pym/portage/package/ebuild/prepare_build_dirs.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Comment 3 Zac Medico gentoo-dev 2018-05-26 06:18:03 UTC
(In reply to Manuel Rüger from comment #0)
> Seeing this traceback, if there's an unclean build directory, that the
> current user has no access to:
> 
> Appending /home/mruger/repos/gentoo to PORTDIR_OVERLAY...
> Forcing test.
> >>> Creating Manifest for /home/mruger/repos/gentoo/app-admin/keepass
> rm: cannot remove
> '/var/tmp/portage/app-admin/keepass-2.39.1/image/usr/share/keepass/XSL/
> KDBX_PasswordsOnly_TXT.xsl': Permission denied
> rm: cannot remove
> '/var/tmp/portage/app-admin/keepass-2.39.1/image/usr/share/keepass/XSL/
> KDBX_Tabular_HTML.xsl': Permission denied
> rm: cannot remove
> '/var/tmp/portage/app-admin/keepass-2.39.1/image/usr/share/keepass/XSL/
> KDBX_Common.xsl': Permission denied

Despite the rm call failing, `ebuild foo.ebuild clean` still returns successful exit status, so we should fix that.