[PR #3457] [MERGED] fix(native): keep export names ending in a carriage return #5748

Closed
opened 2026-10-31 01:09:08 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3457
Author: @HawkForge
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @morluto

Base: main ← Head: fix/macho-export-carriage-return


📝 Commits (1)

  • 2be0393 fix(native): keep export names ending in a carriage return

📊 Changes

3 files changed (+46 additions, -8 deletions)

View changed files

📝 src/native/NativeMachoInspection.ts (+6 -4)
📝 src/native/parsers/dyldInfo.ts (+6 -4)
📝 tests/boundary/providers/native/nativeInventory.golden.test.ts (+34 -0)

📄 Description

Summary

Fixes #3390. inspect-macho now keeps the distinct exports "trailing\r" and "trailing" as two entries with their own addresses. Previously they merged into a single "trailing" entry.

Problem and expected behavior

nm -gjU and dyld_info -exports end each row with LF, and a symbol name may itself end in a carriage return. Captured on macOS arm64 from the issue's executable:

nm:        b'__mh_execute_header\n_main\ntrailing\ntrailing\r\n'
dyld_info: b'...        0x00000330  trailing\n        0x00000328  trailing\r\n'

parseNmExports, parseDyldSymbols, and the export-coverage check (namesEveryExport) split on /\r?\n/ and/or trim() each row. That treated the name's trailing \r as part of the line terminator, so both rows became "trailing" and uniqueSymbols kept only one. The issue expects both exact names to be retained with their native addresses.

Change and scope

  • parseNmExports and namesEveryExport (src/native/NativeMachoInspection.ts) split on "\n" only.
  • parseDyldSymbols (src/native/parsers/dyldInfo.ts) splits on "\n". Export rows now strip only leading indentation, and the export-row regexes use the s flag so a name can contain \r. Import rows keep their current trim() handling.

Out of scope: names containing an embedded LF, which cannot be framed in this line-oriented output.

The adjacent install-name whitespace issue #3384 is handled separately in #3430; this PR doesn't touch otool parsing.

Ordinary fix within existing boundaries; scope decision not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Mach-O export parsing of captured nm/dyld_info output.
  • Contribution scope fit and linked maintainer decision: not applicable (bug fix).
  • CLI and MCP/tool-catalog contract: unchanged schema; export names now match the native names exactly.
  • Provider, bridge, target-format, or platform compatibility: macOS native provider only.
  • Evidence, artifact, provenance, or reconstruction contract: export identities and addresses are no longer merged.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): unchanged; the same commands run.
  • Generated metadata, package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/providers/native/nativeInventory.golden.test.ts — "keeps an export name ending in a carriage return distinct" replays the captured nm and dyld_info -exports output above through inspect_macho. It expects trailing at 0x100000330 and trailing\r at 0x100000328, with no nm rerun. The rows are inline strings because .gitattributes normalizes fixture files to LF.
  • Base reproduction or other evidence: with the source change reverted, the new test fails. On base, the CLI returns only ["trailing","0x100000330"] for the issue's executable.
  • User-visible CLI/MCP output (if applicable): after the change, inspect-macho <symbols> --json exits 0 with exports [["__mh_execute_header","0x100000000"],["_main","0x100000338"],["trailing","0x100000330"],["trailing\r","0x100000328"]].
  • Remaining proof gaps: verified on one macOS arm64 host (Command Line Tools clang/nm/dyld_info); other toolchain versions not checked.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • New test with the fix reverted — fails
  • npx vitest run tests/boundary/providers/native src/native — 562 passed
  • npm run check:fast — passed
  • npm run check — passed
  • Built the issue's symbols.c with xcrun clang, then ran node scripts/rea.mjs inspect-macho <symbols> --json before/after — one merged trailing → two distinct entries (macOS arm64, Node 24.13)

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: real Apple nm/dyld_info on macOS arm64 for the CLI check.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no change to commands run or files read.

Author readiness

Human owner: @HawkForge

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/3457 **Author:** [@HawkForge](https://github.com/HawkForge) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/macho-export-carriage-return` --- ### 📝 Commits (1) - [`2be0393`](https://github.com/morluto/rea/commit/2be0393e4b77eaf6c79d7bfcf370c9771ee071af) fix(native): keep export names ending in a carriage return ### 📊 Changes **3 files changed** (+46 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `src/native/NativeMachoInspection.ts` (+6 -4) 📝 `src/native/parsers/dyldInfo.ts` (+6 -4) 📝 `tests/boundary/providers/native/nativeInventory.golden.test.ts` (+34 -0) </details> ### 📄 Description ## Summary Fixes #3390. `inspect-macho` now keeps the distinct exports `"trailing\r"` and `"trailing"` as two entries with their own addresses. Previously they merged into a single `"trailing"` entry. ## Problem and expected behavior `nm -gjU` and `dyld_info -exports` end each row with LF, and a symbol name may itself end in a carriage return. Captured on macOS arm64 from the issue's executable: ``` nm: b'__mh_execute_header\n_main\ntrailing\ntrailing\r\n' dyld_info: b'... 0x00000330 trailing\n 0x00000328 trailing\r\n' ``` `parseNmExports`, `parseDyldSymbols`, and the export-coverage check (`namesEveryExport`) split on `/\r?\n/` and/or `trim()` each row. That treated the name's trailing `\r` as part of the line terminator, so both rows became `"trailing"` and `uniqueSymbols` kept only one. The issue expects both exact names to be retained with their native addresses. ## Change and scope - `parseNmExports` and `namesEveryExport` (`src/native/NativeMachoInspection.ts`) split on `"\n"` only. - `parseDyldSymbols` (`src/native/parsers/dyldInfo.ts`) splits on `"\n"`. Export rows now strip only leading indentation, and the export-row regexes use the `s` flag so a name can contain `\r`. Import rows keep their current `trim()` handling. Out of scope: names containing an embedded LF, which cannot be framed in this line-oriented output. The adjacent install-name whitespace issue #3384 is handled separately in #3430; this PR doesn't touch `otool` parsing. Ordinary fix within existing boundaries; scope decision not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: Mach-O export parsing of captured `nm`/`dyld_info` output. - Contribution scope fit and linked maintainer decision: not applicable (bug fix). - CLI and MCP/tool-catalog contract: unchanged schema; export names now match the native names exactly. - Provider, bridge, target-format, or platform compatibility: macOS native provider only. - Evidence, artifact, provenance, or reconstruction contract: export identities and addresses are no longer merged. - Target selection, authority, upstream behavior, and cleanup details (if applicable): unchanged; the same commands run. - Generated metadata, package, or installation impact: none. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `tests/boundary/providers/native/nativeInventory.golden.test.ts` — "keeps an export name ending in a carriage return distinct" replays the captured `nm` and `dyld_info -exports` output above through `inspect_macho`. It expects `trailing` at `0x100000330` and `trailing\r` at `0x100000328`, with no `nm` rerun. The rows are inline strings because `.gitattributes` normalizes fixture files to LF. - Base reproduction or other evidence: with the source change reverted, the new test fails. On base, the CLI returns only `["trailing","0x100000330"]` for the issue's executable. - User-visible CLI/MCP output (if applicable): after the change, `inspect-macho <symbols> --json` exits 0 with exports `[["__mh_execute_header","0x100000000"],["_main","0x100000338"],["trailing","0x100000330"],["trailing\r","0x100000328"]]`. - Remaining proof gaps: verified on one macOS arm64 host (Command Line Tools clang/nm/dyld_info); other toolchain versions not checked. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - New test with the fix reverted — fails - `npx vitest run tests/boundary/providers/native src/native` — 562 passed - `npm run check:fast` — passed - `npm run check` — passed - Built the issue's `symbols.c` with `xcrun clang`, then ran `node scripts/rea.mjs inspect-macho <symbols> --json` before/after — one merged `trailing` → two distinct entries (macOS arm64, Node 24.13) ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: real Apple `nm`/`dyld_info` on macOS arm64 for the CLI check. - Package or release metadata impact: none. - Security, privacy, process, or containment review: no change to commands run or files read. ## Author readiness Human owner: @HawkForge - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [ ] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [ ] The PR has one focused outcome and the title follows `type(scope): outcome`. - [ ] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [ ] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:09:08 +00:00
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#5748
No description provided.