patchelf icon indicating copy to clipboard operation
patchelf copied to clipboard

Core dump, empty interpreter

Open cf4f67 opened this issue 3 years ago • 9 comments

Describe the bug

The program produces a core dump (crashes).

Steps To Reproduce

patchelf --set-interpreter /path-to/ld-linux.so BinaryWithEmptyInterpreter.binary produces a core dump.

The binary with empty interpreter that triggered the issue for me can be found in zipped form at https://ufile.io/y3pvil2z (38MB zipped, 136MB unzipped).

Expected behavior

Not a program crash. Maybe a no-op with an informative message.

patchelf --version output

patchelf 0.14.5

Additional context

https://github.com/yvt/nixpkgs/commit/49be2c828875522289e2250307e85c48625bccc7#commitcomment-70690616

cf4f67 avatar Apr 07 '22 08:04 cf4f67

Maybe fixed by https://github.com/NixOS/patchelf/pull/376 ?

Mic92 avatar May 21 '22 12:05 Mic92

There is now a new patchelf release and the file provided here is no longer available

Mic92 avatar Jul 16 '22 05:07 Mic92

Sorry for late replay, if still interested in the file here it is in parts smaller than the 25MB github upload limit,

SomeUE4DebugBinary.debug.aa.zip SomeUE4DebugBinary.debug.ab.zip

Then, to get the full 136MB binary,

cat *.aa.zip *.ab.zip > SomeDebugBinary.zip
unzip SomeDebugBinary.zip

cf4f67 avatar Oct 04 '22 07:10 cf4f67

$ nix shell github:NixOS/patchelf
$ patchelf --version
patchelf 0.15.0
$ patchelf --set-interpreter /path-to/ld-linux.so UnrealVersionSelector-Linux-Shipping.debug
patchelf: patchelf.cc:809: void ElfFile<Elf_Ehdr, Elf_Phdr, Elf_Shdr, Elf_Addr, Elf_Off, Elf_Dyn, Elf_Sym, Elf_Verneed, Elf_Versym>::rewriteSectionsExecutable() [with Elf_Ehdr = Elf64_Ehdr; Elf_Phdr = Elf64_Phdr; Elf_Shdr = Elf64_Shdr; Elf_Addr = long unsigned int; Elf_Off = long unsigned int; Elf_Dyn = Elf64_Dyn; Elf_Sym = Elf64_Sym; Elf_Verneed = Elf64_Verneed; Elf_Versym = short unsigned int]: Assertion `startAddr % getPageSize() == startOffset % getPageSize()' failed.
Aborted (core dumped)

cf4f67 avatar Oct 04 '22 07:10 cf4f67

Ok. So this is not quite a crash but a failed assertion. Also this assertion could be turned into a better error message.

Mic92 avatar Oct 09 '22 12:10 Mic92