← Back to issue list

fix(linter): skip foreign-arch ELF files in library linter

View original Github issue

Metadata

Project
snapcraft
Number
#6249
Type
pull request
State
open
Author
lengau
Labels
—
Created
Updated
Closed
—

Current evaluation

Maintainer PR adding elf_machine to _ArchConfig and get_host_elf_machine() so the library linter skips foreign-arch ELF files, avoiding QEMU/binfmt crashes on cross-arch builds. Approved, core CI green; only CLA and OSV-scanner fail.

Suggested action: needs review

Reason: Author lengau is a maintainer and the review status is 'approved (1 reviewers)' with the full unit/integration spread suites passing; the only red checks are 'Canonical CLA' (signature/admin step) and 'Security scan / OSV-scanner', neither of which points at this diff. Five unresolved review comments and a 139-day age with activity only 2 days ago suggest some reviewer discussion is still pending, so it is not ready to land unattended. Note one design caveat worth raising: comparing e_machine against the host means every file in an arm64-on-amd64 build is skipped, so the linter silently no-ops rather than validating the target arch (relevant to the sibling complaint in #4373 that it 'can't be disabled').

Evaluated by: mr-cal-bot

Impact: 50 Quick Win: 26 Complexity: 28 Confidence: 82 Actionability: 72

Issue body

The library linter calls load_dependencies() on every ELF file found in the prime directory. For foreign-arch builds (e.g. arm64 snap on an amd64 host) this invokes QEMU via binfmt to run the foreign binary, which fails with 'not a dynamic executable' errors and can SEGFAULT, producing multi-gigabyte core dumps. Add elf_machine field to _ArchConfig and get_host_elf_machine() to elf_utils.py. In library_linter.run(), skip any ELF file whose arch_tuple[2] (e_machine) does not match the host's expected value. Fixes: https://github.com/canonical/snapcraft/issues/4373 --- - [x] I've followed the [contribution guidelines](https://github.com/canonical/snapcraft/blob/main/CONTRIBUTING.md). - [x] I've signed the [CLA](http://www.ubuntu.com/legal/contributors/). - [x] I've successfully run `make lint && make test`. - [ ] I've added or updated any relevant documentation. - [ ] In documents I changed, I [added a meta description](https://canonical-starflow.readthedocs-hosted.com/how-to/add-a-page-meta-description/) if one was missing. - [ ] I've updated the relevant release notes.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 50
Quick Win: 26
Complexity: 28
Confidence: 82
Actionability: 72
needs review Maintainer PR adding elf_machine to _ArchConfig and get_host_elf_machine() so the library linter skips foreign-arch ELF files, avoiding QEMU/binfmt crashes on cross-arch builds. Approved, core CI green; only CLA and OSV-scanner fail.
stealth/space-bunny-alpha
Impact: 52
Quick Win: 21
Complexity: 26
Confidence: 72
Actionability: 55
keep open Maintainer-authored fix (snapcraft#6249) making the library linter skip ELF files whose e_machine differs from the host, avoiding QEMU/binfmt crashes on cross-arch builds. Approved, 2 required CI checks failing.
qwen/qwen3.6-35b-a3b
Impact: 60
Quick Win: 21
Complexity: 30
Confidence: 70
Actionability: 50
needs review Skips foreign-arch ELF files in the library linter to prevent QEMU invocation failures and segfaults during cross-architecture builds. Open, 126 days inactive, CI passing except CLA.
qwen/qwen3.8-27b
Impact: 50
Quick Win: 30
Staleness: 60
Complexity: 40
Confidence: 80
needs review Adds elf_machine to _ArchConfig and get_host_elf_machine() to elf_utils.py, and skips foreign-arch ELF files in the library linter to avoid QEMU segfaults and multi-GB core dumps. Unreviewed ~3.5 months; CLA check failing; issue #4373 still open.
qwen/qwen3.6-35b-a3b
Staleness: 55
Complexity: 20
Confidence: 85
needs review Adds architecture check to library linter to skip foreign-arch ELF files, preventing QEMU crashes and core dumps. Currently pending maintainer review with 6 unresolved comments and a failing CLA check.
qwen3.6-35b-a3b-mtp-q6
Staleness: 15
Complexity: 20
Confidence: 90
needs review Fixes a linter crash and SEGFAULT when processing foreign-arch ELF files by skipping mismatched architectures. Ready for review with passing tests.

Update history

Date Change
updated
updated

Related work

  • Likely Fixed By: canonical/snapcraft#4373 (confidence 92%)

    PR body explicitly states 'Fixes: canonical/snapcraft#4373'; issue is still open and describes the foreign-arch library linter failure plus the maintainer's suggestion to check target arch via readelf.

Related issues

Issue Project State Summary Similarity
#4373 library linter fails on foreign archs and can't be disabled for core20 snapcraft open Cross-arch core20 builds still lint foreign ELF files, causing missing-loader failures or QEMU segfaults and potentially 20+ GB core dumps; open PR #6249 proposes the fix.
78%