Open haboustak opened 4 months ago
I am working on creating an upstream patchelf issue. I think this may be fixed in 0.18.0
, but that release was yanked from PyPI. Maybe because of failing tests?
$ ./patchelf-99c2423 \
--set-interpreter "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" \
--set-rpath "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr" \
--force-rpath \
--no-default-lib
pyart \
; echo $?
0
I think there are 55 non-merge commits to bisect.
$ git log --format=oneline --no-merges 0.17.2..0.18.0 | wc -l
55
git-bisect identified the following commit as required for staticx compatibility
$ git bisect new
65cdee904431d16668f95d816a495bc35a05a192 is the first new commit
commit 65cdee904431d16668f95d816a495bc35a05a192
Author: Breno Rodrigues Guimaraes <brenorg@gmail.com>
Date: Mon Mar 20 07:48:00 2023 -0300
Resize segment mapping rewritten sections if needed
https://github.com/NixOS/patchelf/pull/485
Unfortunately, this is in patchelf 0.18.0, which has been yanked from PyPI and has been rolled back by several dependent projects due to this open bug: https://github.com/NixOS/patchelf/issues/492
I've recently ran into problems running a python script processed with
pyinstaller
andstaticx
when run on Debian 10 (Buster), Linux kernel 4.19. The goal of this meta-issue is to collect several suspected patchelf problems idenfied in other staticx issues and resolve them here.TLDR:
patchelf 0.15.0 or earlier
: Binaries work on Debian 10 (4.19.y) and Debian 12 (6.1.y)patchelf 0.16.0 - 0.17.0
: Binaries SEGFAULT on some Linux kernel versions (Debian 10, 4.19.y)patchelf 0.17.1 or later
: staticx fails to run with patchelf assertionIn the
0.16.0
=>0.17.0
range,patchelf
creates sections that the kernel ELF loader is not happy with. Through a mixture ofstrace
anddmesg
I was able to build this execution log of the failing binary. I think the problem occurs when thestaticx
binary tries to exec the wrapped executable (in this case, my pyinstaller'd script).This trace led me to a patchelf commit that was introduced in
0.17.1
https://github.com/NixOS/patchelf/commit/8d2cb4f9ab8d564904c292099a022ffb3cccd52d
The logic that triggers the kernel crash was added to patchelf in
0.16.0
. It was fixed in patchelf0.17.1
. The kernel crash does not occur when patchelf0.15.0
is used.Some aspect of the changes in commit
8d2cb4f
prevent combining the--set-interpreter
,--set-rpath
, and--no-default-lib
options in the same invocation ofpatchelf
. I am not sure yet what the nature of the change is, but the adjustments to theshiftFile
arguments has thrown off the validation / segment matching when it comes to these cascading section/segment resizes.It's some kind of alignment issue, because if I use smaller values for either interpreter or rpath, patchelf no longer asserts.
If I run
--no-default-lib
first, patchelf succeeds. If I set interpreter and rpath first, I cannot set--no-default-lib
in a later invocation.