Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 826982 - Install hangs in check_dyn_libs_inconsistent()'s glob.glob() call on recursive symlink
Summary: Install hangs in check_dyn_libs_inconsistent()'s glob.glob() call on recursiv...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2021-11-23 22:47 UTC by Sam James
Modified: 2021-12-12 20:21 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 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-11-23 22:47:45 UTC
I noticed that nodejs was hanging after stripping. floppym did some further investigation and he found it hangs at check_dyn_libs_inconsistent's call to glob.glob().

I get strace output like:
openat(AT_FDCWD, "/var/tmp/portage/net-libs/nodejs-16.10.0/image/usr/include/node/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/v8/include/deps/uv/include/src/src/deps/v8/include/deps/uv/include/deps/v8/include/deps/uv/include/src/deps/uv/include/deps/v8", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 7

Interestingly, it keeps going even once it gets ELOOP.

glob.glob() seems to always follow symlinks. There's a bug/feature request for Python to not do this: https://bugs.python.org/issue29475 which doesn't seem to have gone far.

The issue itself is caused by nodejs's self-referential symlink at /usr/include/node/src:
lrwxrwxrwx 1 root root 1 Oct 25 16:00 /usr/include/node/src -> .

We need to adapt/replace the glob.glob() code in check_dyn_libs_inconsistent() with something that doesn't follow symlinks.
Comment 1 Larry the Git Cow gentoo-dev 2021-11-24 17:06:12 UTC
The bug has been referenced in the following commit(s):

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

commit 3b3503bb2769b390e22a4fea42fa56fe4db4ddec
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2021-11-23 22:39:24 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2021-11-23 23:22:32 +0000

    portage/util/_dyn_libs/dyn_libs.py: fix symlink recursion issue
    
    Python's glob.glob() function follows symlinks recursively. Use
    os.walk() instead.
    
    Also re-order the operands to short-circuit the directory walk when
    PROVIDES is not empty.
    
    Bug: https://bugs.gentoo.org/826982
    Fixes: cba2156dba89a22f2858238013469b4d80208854
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 lib/portage/util/_dyn_libs/dyn_libs.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
Comment 2 Mike Gilbert gentoo-dev 2021-12-12 20:21:30 UTC
Should be fixed in 3.0.29.