Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 916242 - sys-apps/portage: test_unshare_net.py incompatible with multiprocessing spawn start method
Summary: sys-apps/portage: test_unshare_net.py incompatible with multiprocessing spawn...
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: 916031
Blocks: 914876
  Show dependency tree
 
Reported: 2023-10-24 18:30 UTC by Zac Medico
Modified: 2023-10-25 05:49 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 Zac Medico gentoo-dev 2023-10-24 18:30:27 UTC
When launching lib/portage/tests/process/test_unshare_net.py via this script that runs pytest with the multiprocessing spawn start method, it fails:

> import multiprocessing
> import sys
> import pytest
> if __name__ == "__main__":
>     multiprocessing.set_start_method("spawn", force=True)
>     sys.exit(pytest.console_main())


> ============================= test session starts ==============================
> platform linux -- Python 3.12.0, pytest-7.4.2, pluggy-1.3.0
> rootdir: portage
> collected 0 items / 1 error
> 
> ==================================== ERRORS ====================================
> ________ ERROR collecting lib/portage/tests/process/test_unshare_net.py ________
> lib/portage/process.py:931: in __call__
>     return self._results[flags]
> E   KeyError: 1073741824
> 
> During handling of the above exception, another exception occurred:
> /usr/lib/python3.12/site-packages/_pytest/runner.py:341: in from_call
>     result: Optional[TResult] = func()
> /usr/lib/python3.12/site-packages/_pytest/runner.py:372: in <lambda>
>     call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
> /usr/lib/python3.12/site-packages/_pytest/python.py:531: in collect
>     self._inject_setup_module_fixture()
> /usr/lib/python3.12/site-packages/_pytest/python.py:545: in _inject_setup_module_fixture
>     self.obj, ("setUpModule", "setup_module")
> /usr/lib/python3.12/site-packages/_pytest/python.py:310: in obj
>     self._obj = obj = self._getobj()
> /usr/lib/python3.12/site-packages/_pytest/python.py:528: in _getobj
>     return self._importtestmodule()
> /usr/lib/python3.12/site-packages/_pytest/python.py:617: in _importtestmodule
>     mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
> /usr/lib/python3.12/site-packages/_pytest/pathlib.py:567: in import_path
>     importlib.import_module(module_name)
> /usr/lib/python3.12/importlib/__init__.py:90: in import_module
>     return _bootstrap._gcd_import(name[level:], package, level)
> <frozen importlib._bootstrap>:1381: in _gcd_import
>     ???
> <frozen importlib._bootstrap>:1354: in _find_and_load
>     ???
> <frozen importlib._bootstrap>:1325: in _find_and_load_unlocked
>     ???
> <frozen importlib._bootstrap>:929: in _load_unlocked
>     ???
> /usr/lib/python3.12/site-packages/_pytest/assertion/rewrite.py:178: in exec_module
>     exec(co, module.__dict__)
> lib/portage/tests/process/test_unshare_net.py:23: in <module>
>     ABILITY_TO_UNSHARE = portage.process._unshare_validate(CLONE_NEWNET)
> lib/portage/process.py:933: in __call__
>     result = self._results[flags] = self._validate(flags)
> lib/portage/process.py:960: in _validate
>     proc.start()
> /usr/lib/python3.12/multiprocessing/process.py:121: in start
>     self._popen = self._Popen(self)
> /usr/lib/python3.12/multiprocessing/context.py:224: in _Popen
>     return _default_context.get_context().Process._Popen(process_obj)
> /usr/lib/python3.12/multiprocessing/context.py:289: in _Popen
>     return Popen(process_obj)
> /usr/lib/python3.12/multiprocessing/popen_spawn_posix.py:32: in __init__
>     super().__init__(process_obj)
> /usr/lib/python3.12/multiprocessing/popen_fork.py:19: in __init__
>     self._launch(process_obj)
> /usr/lib/python3.12/multiprocessing/popen_spawn_posix.py:47: in _launch
>     reduction.dump(process_obj, fp)
> /usr/lib/python3.12/multiprocessing/reduction.py:60: in dump
>     ForkingPickler(file, protocol).dump(obj)
> E   ValueError: ctypes objects containing pointers cannot be pickled
> =========================== short test summary info ============================
> ERROR lib/portage/tests/process/test_unshare_net.py - ValueError: ctypes obje...
> !!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
> =============================== 1 error in 0.59s ===============================
Comment 1 Zac Medico gentoo-dev 2023-10-24 18:35:25 UTC
The portage.process._unshare_validator._validate method passes an unpicklable ctypes object as an argument to multiprocessing.Process.
Comment 2 Larry the Git Cow gentoo-dev 2023-10-24 21:26:11 UTC
The bug has been referenced in the following commit(s):

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

commit f2e8b37f37f01c4152693e01575293c8c611709d
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2023-10-24 19:17:21 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2023-10-24 20:52:30 +0000

    _unshare_validator: multiprocessing spawn compat
    
    Since ctypes objects are not picklable for the multiprocessing
    spawn start method, acquire them in the subprocess.
    
    Bug: https://bugs.gentoo.org/916242
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/portage/process.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
Comment 3 Larry the Git Cow gentoo-dev 2023-10-25 05:49:12 UTC
The bug has been closed via the following commit(s):

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

commit 2b9128b401def05cac46f9e6d66048e5a0d888b8
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-10-25 05:48:31 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-10-25 05:48:40 +0000

    sys-apps/portage: add 3.0.54
    
    Closes: https://bugs.gentoo.org/905869
    Closes: https://bugs.gentoo.org/915551
    Closes: https://bugs.gentoo.org/915896
    Closes: https://bugs.gentoo.org/916106
    Closes: https://bugs.gentoo.org/916108
    Closes: https://bugs.gentoo.org/916112
    Closes: https://bugs.gentoo.org/916116
    Closes: https://bugs.gentoo.org/916139
    Closes: https://bugs.gentoo.org/916141
    Closes: https://bugs.gentoo.org/916142
    Closes: https://bugs.gentoo.org/916149
    Closes: https://bugs.gentoo.org/916182
    Closes: https://bugs.gentoo.org/916231
    Closes: https://bugs.gentoo.org/916235
    Closes: https://bugs.gentoo.org/916240
    Closes: https://bugs.gentoo.org/916242
    Closes: https://bugs.gentoo.org/916245
    Closes: https://bugs.gentoo.org/916248
    Closes: https://bugs.gentoo.org/899898
    Closes: https://bugs.gentoo.org/906129
    Closes: https://bugs.gentoo.org/906156
    Closes: https://bugs.gentoo.org/916031
    Signed-off-by: Sam James <sam@gentoo.org>

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