abuild hangs on linux-6.8 for several packages
Hello! This is a heads-up that after a kernel upgrade Alpine builders might experience hangs, in particular if they build on tmpfs.
Several packages in Alpine use some variation of find -exec sed -i
in apkbuild files for patching. When triggering a rebuild after a recent upgrade to linux-6.8 we found that some packages hang forever performing such patching. For a minimal repro, try in an empty directory on a tmpfs mount:
touch `seq 86`
busybox find -type f -exec sed -i s/a/a/ {} \;
Internally, sed -i
creates a new temporary file and renames it on top of the original file. The kernel then passes those new directory entries to subsequent getdents64 syscalls issued by readdir function used by find
. As far as I can tell, the requisites for hitting the issue are:
- a recent kernel
- tmpfs
- busybox find (I think findutils
find
reads the entire directory up front) - musl libc (Glibc uses a 32 KB buffer in readdir rather than 2 KB)
This makes the issue unlikely to hit on other distributions.
We hit the issue on boca
, smooth
and freeimage
(which invokes find -exec dos2unix
). A git grep
for find .* sed
shows that a few more packages use the same idiom (apenwarr-redo, freac, kitty, opencolorio, osl, py3-qt5, py3-reportlab, py3-setuptools, tcl, tk, xen, codeblocks, fpc, simh).
AFAICT this worked by luck, so I'd suggest to avoid such misuse of find
in apkbuild files. One possibility is to use grep -rl PATTERN | xargs sed -i s/PATTERN/REPLACEMENT/
, provided that REPLACEMENT does not contain PATTERN, which is also more efficient since temporary files are created only for files that actually contain the pattern.