auto-patchelf: catch OSError for ZSTD-compressed ELF sections

pyelftools raises OSError: [Errno 22] Invalid argument (not ELFError)
when calling stream.seek() on ZSTD-compressed ELF sections (SHF_COMPRESSED).
This breaks builds of packages like vscode >= 1.118 that ship such binaries.

Extend the except clauses in populate_cache and auto_patchelf_file to also
catch OSError, consistent with the existing intent of skipping non-parseable
files.

Fixes #519275
This commit is contained in:
Philipp Aigner 2026-05-12 13:16:02 +02:00
commit e837217263

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python3
import argparse
import errno
import os
import pprint
import subprocess
@ -195,6 +196,12 @@ def populate_cache(initial: list[Path], recursive: bool =False) -> None:
except ELFError:
# Not an ELF file in the right format
pass
except OSError as e:
if e.errno == errno.EINVAL:
# pyelftools can raise EINVAL for certain compressed sections.
pass
else:
raise
def find_dependency(soname: str, soarch: str, soabi: str) -> Optional[Path]:
@ -343,6 +350,10 @@ def auto_patchelf_file(logger: Logger, path: Path, runtime_deps: list[Path], app
except ELFError:
return []
except OSError as e:
if e.errno == errno.EINVAL:
return []
raise
# these platforms are packaged in nixpkgs with ld.so in a separate derivation
# than libc.so and friends. keep_libc is mandatory.