Skip to content

fix(parsers): stop reading every RangeError as a format failure - #10602

Merged
morluto merged 7 commits into
mainfrom
refactor/host-range-error
Nov 15, 2026
Merged

morluto merged 7 commits into
mainfrom
refactor/host-range-error

Conversation

@morluto

@morluto morluto commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Mach-O, Objective-C, Swift, and managed metadata readers could turn a stack overflow or host capacity failure into a malformed-input result. This change reports known format failures through the shared ParseFailureError algebra and propagates unexpected host failures. It also reports the Swift vtable decoder cap as a resource limit.

Host range error codes do not identify the operation that failed: reads, writes, and allocations can share them. Only explicit parser failures are treated as input evidence; raw host failures remain unclassified. Bounded readers own their bounds checks. Objective-C and Swift metadata catches now preserve unexpected failures rather than recording partial facts.

Validation

  • Seven focused domain and native metadata test files: 192 tests passed, including a 5,000-protocol recursive fixture and actual Node read, write, and allocation errors.
  • npm run check:fast and architecture guards passed; formatting checked for changed files.
  • Source-derived and local fixture coverage only; no real-provider run was performed for this update.

No schema or migration change. No issue was filed; this was found in an error-boundary audit.

Author readiness

Human owner:

  • 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.

…gebra

Add ParseFailure (malformed, truncated, unsupported, limit, with format,
offset and field) and its one carrier, ParseFailureError, in the domain.
BinaryReader now names truncation and the field it read, and its native
format and resource failures are ParseFailureError subclasses.

Providers projected a format failure with their own instanceof ladder,
and some dropped the selected path from the invalid_format message.
parseFailureAnalysisError now owns that projection for the native,
Go, devicetree, V8, Windows Shortcut and Electron fuse providers.
The V8 code cache, Windows Shortcut and Electron fuse format classes
are removed in favour of the algebra.

The architecture guard counts raw Buffer and DataView reads, plain
Error throws in parser folders and plain JSON.parse of parser input
against baselines that can only shrink.
Mach-O, Swift and Objective-C metadata parsers threw RangeError for a
truncated or malformed record, so their catch sites treated any
RangeError as a partial decode: a call stack overflow or a host string
limit became an "unresolved" metadata reason, and the IL2CPP Mach-O
path reported it as a malformed container.

Those parsers and the CIL method body reader now throw ParseFailureError.
hostRangeErrorKind is the one interpreter of a host RangeError (stack
overflow, host capacity, raw out-of-bounds read), and
parseFailureFromCause admits only a parse failure or a raw
out-of-bounds read as evidence about the input. Fixup stream catch-alls
rethrow host limits. The architecture guard counts the remaining direct
instanceof RangeError checks.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T00:09:31.727352Z be4b888 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The reviewed changes appear safe to merge, with no new blocking issue found.

Summary

Moves known parser failures to ParseFailureError and separates them from unexpected host errors.

  • Parser errors now say what the parser established.
  • Mach-O readers label known format failures and pass other errors through.
  • Objective-C metadata keeps partial facts only for known read failures.
  • Swift metadata separates known read failures from host errors.
  • Managed method bodies report known format failures explicitly.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  R["Bounded Objective-C or Swift read"] --> C{"Expected read failure?"}
  C -->|"Reported parse failure or invalid UTF-8"| P["Keep partial facts and a reason"]
  C -->|"Unexpected host error"| H["Propagate the error"]
  V["Swift vtable exceeds 20,000 slots"] --> L["Report a named decode limit"]
  L --> C
Loading

Reviews (6) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread src/native/AppleObjcProtocols.ts Resolved
Comment thread src/domain/parseFailure.ts Resolved
Comment thread src/native/AppleSwiftVtables.ts Resolved
# Conflicts:
#	docs/development/tool-design.md
#	scripts/verify/architecture-guard-baselines.json
#	scripts/verify/architecture-guards.mjs
#	src/domain/parseFailure.ts
#	src/native/metadata/BinaryContainer.ts
# Conflicts:
#	src/il2cpp/Il2cppBinaryImage.ts
#	src/native/AppleMachoSelection.ts
#	src/native/NativeMachoInspection.ts
@morluto
morluto merged commit 89640a4 into main Nov 15, 2026
52 checks passed
@morluto
morluto deleted the refactor/host-range-error branch November 15, 2026 02:03
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant