emerge will have an infinite loop with some obscure values of PKGDIR. This might happen with other variables, see below. Reproducible: Always Steps to Reproduce: 1. FEATURES='buildpkg' PKGDIR='$(true)' emerge -1 acct-user/man Actual Results: infinite loop - emerge hangs with high CPU% Expected Results: successfully calculates dependencies/emerges OR error about unsupported PKGDIR format I added a breakpoint and this is the traceback: Traceback (most recent call last): File "/usr/lib/python-exec/python3.8/emerge", line 51, in <module> retval = emerge_main() File "/usr/lib/python3.8/site-packages/_emerge/main.py", line 1317, in emerge_main return run_action(emerge_config) File "/usr/lib/python3.8/site-packages/_emerge/actions.py", line 3376, in run_action retval = action_build(emerge_config, spinner=spinner) File "/usr/lib/python3.8/site-packages/_emerge/actions.py", line 530, in action_build not trees[eroot]["bintree"].dbapi.writable: File "/usr/lib/python3.8/site-packages/portage/dbapi/bintree.py", line 102, in writable return os.access(first_existing(self.bintree.pkgdir), os.W_OK) File "/usr/lib/python3.8/site-packages/portage/util/path.py", line 26, in first_existing os.lstat(path) first_existing does infinite loop because it assumes that iter_parents will reach /, but it does not if path == "" as os.path.dirname("") == "" Apart from the infinite loop, is PKGDIR supposed to evaluate? It's not evaluated with PKGDIR='$(true)' emerge --info, but when it reaches the above tracepoint, it's evaluated to ""
Portage version? Is this new? (Assume not?)
Created attachment 688290 [details] emerge --info emerge --info, tested on multiple different configs and different profiles
>Is this new? I dont know, this came up because of a mistake in a personal script
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/portage.git/commit/?id=061a895f7b0a310b374dff03af622b11146337d4 commit 061a895f7b0a310b374dff03af622b11146337d4 Author: Zac Medico <zmedico@gentoo.org> AuthorDate: 2021-02-25 10:14:18 +0000 Commit: Zac Medico <zmedico@gentoo.org> CommitDate: 2021-02-25 10:18:02 +0000 iter_parents: prevent infinite loop after empty os.path.dirname result Reported-by: dkjii@cock.li Bug: https://bugs.gentoo.org/772806 Signed-off-by: Zac Medico <zmedico@gentoo.org> lib/portage/util/path.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)