You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've recently ran into problems running a python script processed with pyinstaller and staticx 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 assertion
In the 0.16.0 => 0.17.0 range, patchelf creates sections that the kernel ELF loader is not happy with. Through a mixture of strace and dmesg I was able to build this execution log of the failing binary. I think the problem occurs when the staticx binary tries to exec the wrapped executable (in this case, my pyinstaller'd script).
The logic that triggers the kernel crash was added to patchelf in 0.16.0. It was fixed in patchelf 0.17.1. The kernel crash does not occur when patchelf 0.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 of patchelf. I am not sure yet what the nature of the change is, but the adjustments to the shiftFile arguments has thrown off the validation / segment matching when it comes to these cascading section/segment resizes.
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?
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 <[email protected]>
Date: Mon Mar 20 07:48:00 2023 -0300
Resize segment mapping rewritten sections if needed
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: NixOS/patchelf#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
NixOS/patchelf@8d2cb4f
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.The text was updated successfully, but these errors were encountered: