elf: properly handle corrupted ELF files
Metadata
Current evaluation
Merged. Snapcraft now catches errors and issues warnings instead of crashing during priming when encountering corrupted ELF files. Test binaries from Qt 5.13 were added, and commits were squashed with source attribution included per reviewer feedback.
Suggested action: —
No scores available.
Issue body
- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [x] Have you successfully run `./runtests.sh static`?
- [x] Have you successfully run `./runtests.sh tests/unit`?
-----
Currently snapcraft dies during the priming step if the snap includes any corrupted ELF files (e.g ELF files where section names aren't strings). Fix this by catching the error and warning when it occurs.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged. Snapcraft now catches errors and issues warnings instead of crashing during priming when encountering corrupted ELF files. Test binaries from Qt 5.13 were added, and commits were squashed with source attribution included per reviewer feedback. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged a fix preventing snapcraft crashes during priming with corrupted ELF files. The code now catches the error and logs a warning. Test binaries from Qt 5.13 were added, and the commit was squashed with requested license attribution. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Snapcraft now catches errors from corrupted ELF files during priming and issues a warning instead of crashing. Test binaries sourced from Qt 5.13, commit message updated with attribution, and squashed per reviewer request. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1976 elf: only consider regular files as possible ELF binaries | snapcraft | merged | Merged a fix restricting ELF binary detection to regular files, resolving Snapcraft core snap build failures caused by device files being misidentified. Approved by reviewers and passed CI checks. | |
| #1881 elf: better handling for newer libc6 | snapcraft | merged | Merged. Updates ELF handling for newer libc6 by requiring explicit libc6 declaration in snapcraft.yaml. Resolves dependency tracking, incorporates reviewer feedback, and passes CI. Segfaults on bionic are managed via adapter configuration. | |
| #1838098 snapcraft prime fails if it finds an invalid ELF file | snapcraft (launchpad) | closed | Abandoned without fix. Snapcraft prime crashes on invalid ELF files due to an unhandled ELFError. No pull request or resolution was provided. | |
| #75 refactor: rewrite elf file support | debcraft | merged | Merged rewrite of ELF file support to better match deb building needs, replacing Snapcraft's implementation. Handles needed libraries; symbol support deferred. Approved by two reviewers, passed all CI checks, and resolves #72. | |
| #2929 elf: fixes for corrupt shared objects | snapcraft | merged | Merged to master. Resolves corrupt shared object handling by catching elftools ConstructErrors and skipping corrupted ELF files during library crawling. Approved, passed CI, and achieved 100% diff coverage. |