Skip to content

fix(artifacts): inventory universal slices REA cannot structurally index - #3283

Merged
kaoru0822-kitauji merged 2 commits into
mainfrom
fix/macho-slices-unsupported-structure
Oct 14, 2026
Merged

kaoru0822-kitauji merged 2 commits into
mainfrom
fix/macho-slices-unsupported-structure

Conversation

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Problem

inspect_artifact and extract_artifact refused a valid universal Mach-O whenever one slice fell outside REA's structural index. On this Mac, /Applications/XLD.app/Contents/MacOS/XLD (an installed, ad-hoc signed app with x86_64, i386, ppc and arm64 slices) failed entirely:

code: artifact_operation_failed, category: execution_failure
message: Artifact is invalid or has changed. Get a fresh copy and try again.
detail: Mach-O structural slice index is unsupported: big-endian Mach-O slices are not supported

The artifact is fine. Only the big-endian PowerPC slice is unsupported, and the "fresh copy" advice is wrong.

Fix

MachOSliceArtifactReader already inventories slices from lipo's ranges, with a limitation, when structural Mach-O facts are unavailable (not-mach-o). An unsupported structural result now takes the same path when lipo reported every slice's offset and size. Each slice carries the limitation Structural Mach-O facts were unsupported (<reason>); slice range is based on lipo output. The existing bounds check against the file size still applies.

When lipo omits a range (for example a thin big-endian file), the reader still fails. It now uses the unavailable reason, which reports missing support for the target, instead of format, which reports a corrupt artifact.

Validation

Real data:

  • rea inspect-artifact /Applications/XLD.app/Contents/MacOS/XLD: before, the error above; after, 4 slices in 1.15 s. Each slice's size and SHA-256 equals the byte range from XLD's FAT table (checked independently in Python).
  • rea extract-artifact on the same binary: before, the same error; after, it succeeds.

Tests:

  • A new darwin case in tests/boundary/providers/native/machoSliceReader.test.ts runs the real lipo on a FAT file with a little-endian arm64 slice and a big-endian ppc slice. It fails on main and passes with this change.
  • npm run test:focused on the slice-reader tests (5 files, 23 tests) passes.
  • npm run check:fast passes.

🤖 Generated with Claude Code

inspect_artifact and extract_artifact rejected a valid universal Mach-O
when one slice was outside the structural index, such as XLD's
big-endian PowerPC slice. The whole inventory failed with "Artifact is
invalid or has changed. Get a fresh copy and try again."

When lipo reports every slice's range, the slices are now inventoried
from those ranges with a limitation naming the unsupported structure,
as the reader already does for files without structural facts. When
lipo omits a range, the failure is reported as unavailable support
rather than a corrupt artifact.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaoru0822-kitauji kaoru0822-kitauji added the track:bugs Small-bug loop track PRs label Oct 14, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; both previous findings are addressed and no new blocking issue was found.

Summary

The PR lets valid universal Mach-O files use complete lipo ranges when REA cannot read every slice's structure.

  • Universal Mach-O files keep their slice inventory when a slice is unsupported.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Read FAT slices] --> B{Can REA read this slice?}
  B -->|Yes| C[Check commands and identity]
  B -->|Unsupported| D[Remember limitation]
  C -->|Malformed| E[Reject artifact]
  C -->|Valid| F[Check next slice]
  D --> F
  F -->|More slices| B
  F -->|Finished| G{Any unsupported slice?}
  G -->|No| H[Use structural facts]
  G -->|Yes| I{Complete lipo ranges?}
  I -->|No| J[Report unavailable support]
  I -->|Yes| K[Check bounds and inventory with limitation]
Loading

Reviews (2) · Last reviewed commit: "fix(artifacts): validate every FAT slice..." · Reviewed by Greptile

readFatSlices returned at the first unsupported slice, so a later
malformed slice went unchecked: with lipo's ranges now inventoried for
unsupported structure, a malformed little-endian slice after a
big-endian one was accepted while the reverse order was rejected.
Unsupported slices are now remembered and the remaining slices are
still validated, so malformed structure wins in either order.

Adds portable fake-lipo coverage for complete ranges, missing ranges
(unavailable) and malformed slices on both sides of a big-endian slice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaoru0822-kitauji
kaoru0822-kitauji merged commit e582859 into main Oct 14, 2026
32 checks passed
@kaoru0822-kitauji
kaoru0822-kitauji deleted the fix/macho-slices-unsupported-structure branch October 14, 2026 08:22
@morluto morluto added area: evidence Evidence, artifacts, and reconstruction bug Something isn't working labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction bug Something isn't working track:bugs Small-bug loop track PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants