[PR #3660] [CLOSED] fix(managed): keep native-boundary inspection alive for very large issue inventories #5867

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3660
Author: @rudycelekli
Created: 10/14/2026
Status: ❌ Closed

Base: main ← Head: fix/managed-boundary-issue-spread-20261014


📝 Commits (2)

  • cf98e2d fix(managed): keep native-boundary inspection alive for very large issue inventories
  • 1a6d5e0 fix(managed): verify complete issue retention through shared appender

📊 Changes

3 files changed (+43 additions, -9 deletions)

View changed files

📝 src/dotnet/ManagedNativeBoundaryInspector.test.ts (+29 -0)
📝 src/dotnet/ManagedNativeBoundaryInspector.ts (+5 -2)
📝 src/dotnet/ManagedPe.fixture.ts (+9 -7)

📄 Description

Summary

inspect_managed_native_boundaries fails outright on a PE/CLI whose metadata yields roughly 140,000 inventory issues, instead of returning its P/Invoke declarations with partial coverage. Fixes #3365.

Problem and expected behavior

Smallest trigger: a managed PE with 140,000 custom-attribute rows whose constructor index is invalid, plus one P/Invoke declaration. inspectManagedNativeBoundariesBytes throws RangeError: Maximum call stack size exceeded at issues.push(...inventory.issues), which the tool reports as a generic execution_failure with no Evidence. Expected: the declaration is retained and coverage is partial with the issues listed, as it already is at 100,000 issues.

Change and scope

The producer of the oversized array is the metadata inventory; the consumer appended it as call arguments. It now delegates to the existing appendManagedParseIssues owner, which appends element by element without argument spreading. The test fixture builder had the same spread over table rows (tablesStream), which had to be fixed for the test to build the 140,000-row table at all.

Not included: src/dotnet/ManagedMemberInspectorCore.ts (issues.push(...memberLists.issues)) and src/domain/managed/managedNativeVerificationMatch.ts have the same pattern, but I did not construct an input that overflows them, so I left them untouched rather than claim an unverified fix.

Not a new provider or capability; an ordinary fix within existing boundaries (scope decision not applicable). Opened as a draft.

Contract and boundary impact

  • Semantic owner and earliest changed stage: managed native-boundary inspection, issue aggregation after metadata inventory.
  • Contribution scope fit and linked maintainer decision: bug fix in an existing read-only inspector; not applicable.
  • CLI and MCP/tool-catalog contract: none; result shape unchanged, previously failing input now returns the existing partial result.
  • Provider, bridge, target-format, or platform compatibility: PE/CLI, platform independent.
  • Evidence, artifact, provenance, or reconstruction contract: none changed; issues and imports are preserved instead of lost.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • 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: src/dotnet/ManagedNativeBoundaryInspector.test.ts (new case, 140,000 custom-attribute rows); src/dotnet/ManagedPe.fixture.ts (fixture no longer spreads table rows).
  • Base reproduction or other evidence (executed): the new test, run against upstream/main production code (with only the fixture fix applied so the input can be built), fails with RangeError: Maximum call stack size exceeded at ManagedNativeBoundaryInspector.test.ts:22. Without the fixture fix the fixture builder itself overflows first (ManagedPe.fixture.ts:570).
  • User-visible CLI/MCP output: not captured; the issue reports a generic execution_failure for this input. I did not run the CLI end to end.
  • Remaining proof gaps: no real-world 140,000-issue assembly tested; the exact overflow threshold is engine- and stack-dependent.

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

Review follow-up at 3cff98ad (Node 24.18.0, npm 11.16.0, locked dependencies):

  • npm run test:focused -- src/dotnet/ManagedNativeBoundaryInspector.test.ts src/dotnet/ManagedMemberInspector.test.ts src/dotnet/ManagedArtifactInspector.test.ts: 179 tests pass across three files.
  • npm run check: passes, including compilation, formatting, built lint, metadata and architecture guards.
  • npm run verify:test-discovery: all 1,298 test files discovered exactly once.
  • The volume regression now requires all 140,000 distinct CustomAttribute issues and non-null, distinct row offsets, while retaining the P/Invoke declaration and partial coverage. An intentional one-issue truncation passes the old assertion and fails the stronger assertion; the fault was removed before the full check.
  • Earlier overflow reproduction and 332-test results above are historical. This follow-up did not run the full test suite, current-main merge tree, hosted CI, or an end-to-end CLI/MCP command. The input remains a synthetic PE fixture.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (static PE metadata parser, synthetic fixture).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: removes an attacker-controlled-input crash (stack overflow from crafted metadata) in a read-only parser; no new capability.

Author readiness

Human owner: @rudycelekli

  • 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/3660 **Author:** [@rudycelekli](https://github.com/rudycelekli) **Created:** 10/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/managed-boundary-issue-spread-20261014` --- ### 📝 Commits (2) - [`cf98e2d`](https://github.com/morluto/rea/commit/cf98e2de3a33078711a11cce682656c5e5689369) fix(managed): keep native-boundary inspection alive for very large issue inventories - [`1a6d5e0`](https://github.com/morluto/rea/commit/1a6d5e0ef22fbea84c747d39783decbf1d9793d6) fix(managed): verify complete issue retention through shared appender ### 📊 Changes **3 files changed** (+43 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `src/dotnet/ManagedNativeBoundaryInspector.test.ts` (+29 -0) 📝 `src/dotnet/ManagedNativeBoundaryInspector.ts` (+5 -2) 📝 `src/dotnet/ManagedPe.fixture.ts` (+9 -7) </details> ### 📄 Description ## Summary `inspect_managed_native_boundaries` fails outright on a PE/CLI whose metadata yields roughly 140,000 inventory issues, instead of returning its P/Invoke declarations with partial coverage. Fixes #3365. ## Problem and expected behavior Smallest trigger: a managed PE with 140,000 custom-attribute rows whose constructor index is invalid, plus one P/Invoke declaration. `inspectManagedNativeBoundariesBytes` throws `RangeError: Maximum call stack size exceeded` at `issues.push(...inventory.issues)`, which the tool reports as a generic `execution_failure` with no Evidence. Expected: the declaration is retained and coverage is `partial` with the issues listed, as it already is at 100,000 issues. ## Change and scope The producer of the oversized array is the metadata inventory; the consumer appended it as call arguments. It now delegates to the existing `appendManagedParseIssues` owner, which appends element by element without argument spreading. The test fixture builder had the same spread over table rows (`tablesStream`), which had to be fixed for the test to build the 140,000-row table at all. Not included: `src/dotnet/ManagedMemberInspectorCore.ts` (`issues.push(...memberLists.issues)`) and `src/domain/managed/managedNativeVerificationMatch.ts` have the same pattern, but I did not construct an input that overflows them, so I left them untouched rather than claim an unverified fix. Not a new provider or capability; an ordinary fix within existing boundaries (scope decision not applicable). Opened as a draft. ## Contract and boundary impact - Semantic owner and earliest changed stage: managed native-boundary inspection, issue aggregation after metadata inventory. - Contribution scope fit and linked maintainer decision: bug fix in an existing read-only inspector; not applicable. - CLI and MCP/tool-catalog contract: none; result shape unchanged, previously failing input now returns the existing partial result. - Provider, bridge, target-format, or platform compatibility: PE/CLI, platform independent. - Evidence, artifact, provenance, or reconstruction contract: none changed; issues and imports are preserved instead of lost. - Target selection, authority, upstream behavior, and cleanup details: not applicable. - Generated metadata, package, or installation impact: none. Expected effects: - [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: `src/dotnet/ManagedNativeBoundaryInspector.test.ts` (new case, 140,000 custom-attribute rows); `src/dotnet/ManagedPe.fixture.ts` (fixture no longer spreads table rows). - Base reproduction or other evidence (executed): the new test, run against `upstream/main` production code (with only the fixture fix applied so the input can be built), fails with `RangeError: Maximum call stack size exceeded` at `ManagedNativeBoundaryInspector.test.ts:22`. Without the fixture fix the fixture builder itself overflows first (`ManagedPe.fixture.ts:570`). - User-visible CLI/MCP output: not captured; the issue reports a generic `execution_failure` for this input. I did not run the CLI end to end. - Remaining proof gaps: no real-world 140,000-issue assembly tested; the exact overflow threshold is engine- and stack-dependent. 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 Review follow-up at `3cff98ad` (Node 24.18.0, npm 11.16.0, locked dependencies): - `npm run test:focused -- src/dotnet/ManagedNativeBoundaryInspector.test.ts src/dotnet/ManagedMemberInspector.test.ts src/dotnet/ManagedArtifactInspector.test.ts`: 179 tests pass across three files. - `npm run check`: passes, including compilation, formatting, built lint, metadata and architecture guards. - `npm run verify:test-discovery`: all 1,298 test files discovered exactly once. - The volume regression now requires all 140,000 distinct CustomAttribute issues and non-null, distinct row offsets, while retaining the P/Invoke declaration and partial coverage. An intentional one-issue truncation passes the old assertion and fails the stronger assertion; the fault was removed before the full check. - Earlier overflow reproduction and 332-test results above are historical. This follow-up did not run the full test suite, current-main merge tree, hosted CI, or an end-to-end CLI/MCP command. The input remains a synthetic PE fixture. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: not applicable (static PE metadata parser, synthetic fixture). - Package or release metadata impact: none. - Security, privacy, process, or containment review: removes an attacker-controlled-input crash (stack overflow from crafted metadata) in a read-only parser; no new capability. ## Author readiness <!-- The human owner completes these declarations before requesting review. The PR author is the owner by default. A different owner must explicitly accept ownership on this PR. AI agents must leave these declarations to a human to dictate to them or there could be catastrophic consequences for many users of REA. Draft PRs may leave them unchecked. These declarations record initial readiness when opening the PR for review; later pushes do not require a new human sign-off. Keep the description and validation evidence current as the work changes. See CONTRIBUTING.md#pull-request-ownership-and-readiness. --> Human owner: @rudycelekli - [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 <!-- Draft PRs may leave pending items unchecked. Resolve material scope and authority questions before integration. --> - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [x] 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:10:03 +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#5867
No description provided.