Conversation
|
Commit 98fe471 has started to follow the symbolic links to fix Alioth #313461. This PR doesn't seem to pay attention to that. |
|
@akinomyoga Thanks for pointing out 98fe471. The fix has been updated to
Tested with 10 scenarios + 3 benchmarks in a virtme-ng VM, |
51a497e to
1ef1c87
Compare
_comp_compgen_kernel_modules() used `ls -RL` to recursively list module files. The -L flag (added in 98fe471 to follow symlinks for distros that organize modules via symlinked subdirectories) also follows the `build` and `source` symlinks created by the kernel build system (scripts/Makefile.modinst), which point to the full kernel build/source tree. When the build tree is large (common with O= out-of-tree builds), following these symlinks recursively opens hundreds of thousands of files. This can exhaust the system file table (ENFILE) and cause shared library loading failures for completion helpers: $ modprobe iok<TAB> sed: error while loading shared libraries: libc.so.6: cannot open shared object file: Error 23 Additionally, the old `sed` regex `\.k\{0,1\}o` (from 2003, for kernel 2.4 `.o` module backward compat) matches both `.ko` and `.o` files, producing false positives from build tree objects. Replace `ls -RL | sed` with `find -L` that preserves symlink following but prunes the top-level build/source entries: find -L "$_modpath" \ \( -path "$_modpath/build" -o \ -path "$_modpath/source" \) -prune -o \ \( -name "*.ko" -o -name "*.ko.gz" -o -name "*.ko.xz" \ -o -name "*.ko.zst" \) -print - `-L` follows symlinks (preserves 98fe471 behavior) - `-path` only prunes top-level build/source, not nested dirs - `-name "*.ko"` uses glob matching (no false .o positives) - `-print` outside the -o group avoids short-circuit evaluation Signed-off-by: Chao Huang <huangchao@kylin.com>
1ef1c87 to
160a55a
Compare
Problem
_comp_compgen_kernel_modules()usesls -RLto recursively list modulefiles under
/lib/modules/$(uname -r)/. The-Lflag (added in 98fe471to follow symlinks for distros that organize modules via symlinked
subdirectories) also follows the
buildandsourcesymlinks created bythe kernel build system (
scripts/Makefile.modinst), which point to thefull kernel build/source tree.
When the build tree is large (common with
O=out-of-tree builds),following these symlinks recursively opens hundreds of thousands of files.
This can exhaust the system file table (ENFILE) and cause shared library
loading failures for completion helper programs:
Additionally, the old
sedregex\.k\{0,1\}o(from 2003, for kernel 2.4.omodule backward compatibility) matches both.koand.ofiles,producing false positives from build tree object files.
Fix
Replace
ls -RL | sedwithfind -Lusing-pathto prune only thetop-level
build/sourcesymlinks:-Lfollows symlinks (preserves 98fe471 behavior)-pathonly prunes top-levelbuild/source, not nested dirs-name '*.ko'uses exact glob matching, no false.opositives-printoutside the-ogroup avoids short-circuit evaluationTest results
10 scenarios + 3 benchmarks, all passing in a virtme-ng VM:
.ofalse positive verificationls -RL)find -L)