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

Vincent Lefevre vincent at vinc17.net
Wed Sep 8 01:21:46 BST 2021


On 2021-09-07 22:22:34 +0000, David wrote:
> 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"

No, this wouldn't help, because the libc6 version zsh-static has
been compiled against would be the same as the one for the test.

Here, the issue is that zsh-static is built against some libc6
version (at this time, zsh-static would work as expected), then
libc6 is upgraded to some newer version, and zsh-static no longer
works.

I'd say that it would be difficult to design a test framework for
up-to-date Debian/unstable that would be useful in practice (since
as soon as a new version of some package gets in unstable, all the
other packages would need to be tested), except for non-regression
tests about particular bugs like this one.

> 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

Perhaps.

> 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

busybox is dynamically linked:

$ file /bin/busybox
/bin/busybox: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=280a5ddfb6379abacc1a6c7a6024876f653cd6bf, for GNU/Linux 3.2.0, stripped

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

I confirm that no shared libraries are read with -static on simple
programs.

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



More information about the Pkg-zsh-devel mailing list