[GH-ISSUE #1502] fix(native): select the FAT slice for the admitted CPU type #512

Closed
opened 2026-10-15 18:25:44 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @cursor[bot] on GitHub (Oct 10, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/1502

TL;DR: inspect_native_dispatch_metadata treats every architecture other than arm64 as the x86_64 slice. On a universal binary that also contains x86_64, an admitted x86 or arm target is decoded as x86_64.

BinaryArchitecture is x86 | x86_64 | arm | arm64. Admission already maps those to Mach-O CPU types 7, 0x01000007, 12, and 0x0100000c (machArchitecture in src/domain/binaryTarget.ts). Slice selection does not use that table.

Area

Native Mach-O inspection

Observed behavior

selectMachoSlice in src/native/AppleMachoSelection.ts sets:

const cpu = architecture === "arm64" ? 0x0100000c : 0x01000007;

decodeAppleDispatchMetadata passes target.architecture straight through. A FAT file with an i386 slice (CPU type 7) and an x86_64 slice (0x01000007), opened as architecture x86, selects the x86_64 slice. That slice is little-endian 64-bit, so the later 0xfeedfacf check accepts it. Objective-C and Swift metadata, fixups, and segments are then reported for the wrong slice.

An arm target on a FAT that also contains x86_64 takes the x86_64 slice the same way. An arm or x86 target whose only slice is 32-bit fails with "Requested FAT architecture is absent" instead of "32-bit metadata is unsupported".

selectArchitecture in src/native/NativeMachoInspection.ts has the matching hole for otool / nm / dyld_info. After the lipo list does not contain the admitted name, and arm64e recovery does not apply, it still return normalized. The tools are invoked with -arch for a slice lipo did not list.

Expected behavior

Slice selection should use the same CPU-type table as admission. A 32-bit slice should fail as unsupported 32-bit metadata, with the requested CPU type named. A tool invocation should not pass -arch for a name absent from the lipo list for that file.

Where

  • src/native/AppleMachoSelection.ts — selectMachoSlice
  • src/native/AppleDispatchMetadata.ts — decodeAppleDispatchMetadata call with target.architecture
  • src/domain/binaryTarget.ts — machArchitecture
  • src/native/NativeMachoInspection.ts — selectArchitecture
Originally created by @cursor[bot] on GitHub (Oct 10, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/1502 **TL;DR:** `inspect_native_dispatch_metadata` treats every architecture other than `arm64` as the x86_64 slice. On a universal binary that also contains x86_64, an admitted `x86` or `arm` target is decoded as x86_64. `BinaryArchitecture` is `x86 | x86_64 | arm | arm64`. Admission already maps those to Mach-O CPU types 7, `0x01000007`, 12, and `0x0100000c` (`machArchitecture` in `src/domain/binaryTarget.ts`). Slice selection does not use that table. ### Area Native Mach-O inspection ### Observed behavior `selectMachoSlice` in `src/native/AppleMachoSelection.ts` sets: ```ts const cpu = architecture === "arm64" ? 0x0100000c : 0x01000007; ``` `decodeAppleDispatchMetadata` passes `target.architecture` straight through. A FAT file with an i386 slice (CPU type 7) and an x86_64 slice (`0x01000007`), opened as architecture `x86`, selects the x86_64 slice. That slice is little-endian 64-bit, so the later `0xfeedfacf` check accepts it. Objective-C and Swift metadata, fixups, and segments are then reported for the wrong slice. An `arm` target on a FAT that also contains x86_64 takes the x86_64 slice the same way. An `arm` or `x86` target whose only slice is 32-bit fails with "Requested FAT architecture is absent" instead of "32-bit metadata is unsupported". `selectArchitecture` in `src/native/NativeMachoInspection.ts` has the matching hole for `otool` / `nm` / `dyld_info`. After the lipo list does not contain the admitted name, and arm64e recovery does not apply, it still `return normalized`. The tools are invoked with `-arch` for a slice lipo did not list. ### Expected behavior Slice selection should use the same CPU-type table as admission. A 32-bit slice should fail as unsupported 32-bit metadata, with the requested CPU type named. A tool invocation should not pass `-arch` for a name absent from the lipo list for that file. ### Where - `src/native/AppleMachoSelection.ts` — `selectMachoSlice` - `src/native/AppleDispatchMetadata.ts` — `decodeAppleDispatchMetadata` call with `target.architecture` - `src/domain/binaryTarget.ts` — `machArchitecture` - `src/native/NativeMachoInspection.ts` — `selectArchitecture`
bsakaguchi 2026-10-15 18:25:44 +00:00
Author
Owner

@morluto commented on GitHub (Oct 10, 2026):

Thanks for reporting this. Closing as resolved on main. FAT selection uses the admitted architecture-to-CPU mapping, rejects unsupported 32-bit metadata explicitly, and refuses tool invocation for an architecture absent from lipo output.

Merged fix. I checked the current source against this report; no tests or real-provider workflows were run for this closure pass.

<!-- gh-comment-id:6099800390 --> @morluto commented on GitHub (Oct 10, 2026): Thanks for reporting this. Closing as resolved on main. FAT selection uses the admitted architecture-to-CPU mapping, rejects unsupported 32-bit metadata explicitly, and refuses tool invocation for an architecture absent from lipo output. [Merged fix](https://github.com/morluto/rea/commit/b4db35f092d7166aebdf4387b48f7652b1d1c3b6). I checked the current source against this report; no tests or real-provider workflows were run for this closure pass.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#512
No description provided.