[Pkg-zsh-devel] Bug#993843: Bug#993843: zsh-static segfaults immediately

David dvddbnrprtbg at ad5ey.net
Tue Sep 7 23:22:34 BST 2021


On Tue, Sep 07, 2021 at 12:23:38PM +0200, Axel Beckert wrote:
>...
>David wrote:
>>...
>
>Sorry for the trouble. I (and the tests) admittedly only test the
>non-static zsh. And except for some special lookups known to be not
>possible with static compiled binaries, I also don't expect any
>difference in functionality with zsh-static.

Thank you both so much for looking into it!  And Vincent noticing that 
/lib/x86_64-linux-gnu/libc.so.6 is being opened and mapped into memory 
is very eye opening, for a static binary!

Please forgive my ignorange in the automated test suites, but perhaps 
for a future test, would verifying the expected exit status of these 
commands help intercept this (and any other) weird problem?  :-)

   zsh-static -f -c "exit 0"
   zsh-static -f -c "exit 1"


Now for a more thorough test:  Is it possible (or even desireable?) to 
test the binary to verify it really is statically linked?  Perhaps grep 
strace output looking for potential evidence of .so files getting opened 
in some lib directory?

> strace zsh-static -f -c "exit 0" 2>&1 | grep '^open[a-zA-Z0-9_]*(.*"[^"]*lib.*\.so\>[^"]*"'
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libnss_compat.so.2", O_RDONLY|O_CLOEXEC) = 11
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 11
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2", O_RDONLY|O_CLOEXEC) = 11
> echo $?
0

For comparison, busybox is statically linked:

> strace /bin/busybox -f -c "exit 0" 2>&1 | grep '^open[a-zA-Z0-9_]*(.*"[^"]*lib.*\.so\>[^"]*"' 
> echo $?
1

(And I also just tested a couple small C programs invoking printf and 
compiled with and without "-static".)

There's gotta be a better test to detect run-time opening of shared 
libraries.  (My regex of looking for open...("... .so ...") feels 
hackish.)

- David



More information about the Pkg-zsh-devel mailing list