Skip to content

fix(managed): resolve member ownership through pointer tables - #1886

Merged
morluto merged 1 commit into
morluto:mainfrom
chqcjq:fix/managed-member-pointer-ownership
Oct 11, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
chqcjq:fix/managed-member-pointer-ownership

Conversation

@chqcjq

@chqcjq chqcjq commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Resolve declaring-type ownership through FieldPtr and MethodPtr for unoptimized managed metadata. Physical Field/MethodDef tokens remain unchanged, while member owners and local custom-attribute constructor types follow the metadata's pointer ordering.

This is the pre-existing defect identified in the #1706 review, which the author explicitly deferred to a separate shared-owner fix. It does not implement type selection or the separate cursor-budget work in #1878.

Problem and expected behavior

REA admits #- metadata but compares physical Field/MethodDef row numbers directly against TypeDef list positions. Those coordinates differ when a pointer table reorders the definitions.

A 4 KiB source-owned fixture has <Module>, Fixture.A, Fixture.B, two fields and two methods, and pointer rows [2,1]. On base fb94d9dd, the first physical field/method is incorrectly attributed to A and the second to B, with complete coverage. A custom attribute whose constructor is physical MethodDef row 1 also receives the wrong type name.

Expected: physical row 1 belongs to B and row 2 to A; their tokens remain 0x04000001/02 and 0x06000001/02. Microsoft's System.Reflection.Metadata/PEReader independently produced that ownership for the same fixture without loading or executing the assembly.

Change and scope

  • Share a per-layout inverse pointer lookup between member and attribute-constructor inspection. Read list widths from both pointer and definition tables, and use nonempty pointer-table counts for list bounds.
  • Reserve retained index capacity before creating its containers. Cache the lookup, including malformed-table failures, to avoid repeated scans/charges.
  • Reject zero, out-of-range and ambiguous pointers as typed coverage issues. Keep readable member names/tokens and custom-attribute parent/constructor/value facts; only an unresolvable owner/type name becomes unknown.
  • Document that TypeDef list ranges retain list-slot coordinates, which need not be contiguous physical definition rows.

The implementation changes the shared interpretation, rather than patching a selected-type filter. Existing direct-list behavior and malformed TypeDef first-match behavior remain covered. No cursor/CIL/string/projection budget was removed or increased.

Contract and boundary impact

  • Semantic owner and earliest changed stage: static PE/CLI metadata interpretation in src/dotnet.
  • CLI/MCP/tool catalog: no schema change. Corrected ownership and preserved partial facts use existing fields.
  • Provider/format/platform: FieldPtr/MethodPtr support in the portable static reader; no external engine, target execution, or native mutation.
  • Evidence/provenance: preserve physical member tokens, row offsets, artifact identity and valid attribute payload facts. Pointer list positions are not substituted for definition tokens.
  • Process/authorization/cleanup: no new process or authority behavior.
  • Generated metadata/package/installation: no dependency or version change; generated outputs are not committed.

Evidence and regression coverage

  • Executed baseline: three independent failures for field ownership, method ownership and local attribute-constructor type; identity-pointer and ordinary #~ controls passed.
  • Nineteen parser regressions cover reordered/identity/absent/empty pointer tables, both tables' zero/out-of-range/duplicate/omitted entries, truncated admitted table extents, and preservation of independent member/attribute facts.
  • Two budget regressions use a small real fixture: insufficient budget results in zero Uint32Array constructions; enough budget for one lookup permits reuse with no second allocation or charge. These check admission ordering, not a hard bound on all V8 heap use.
  • A compiled CLI/real stdio MCP acceptance test compares artifact/member results and validates the unchanged fixture digest and physical tokens.
  • Independent Microsoft metadata-reader check of the same generated PE confirmed the expected reordered ownership. This is a synthetic fixture accepted by an independent reader, not a claim about arbitrary compiler-produced binaries.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity and source provenance remain preserved.
  • Partial and uncertain outcomes remain visible.

Validation performed

On Windows x64 with the pinned Node 24.18.0 / npm 11.16.0:

  • npm run test:local -- <all 10 src/dotnet/*.test.ts files> — 158 passed, no failures or skips.
  • npm run test:focused -- tests/acceptance/managedMemberPointers.test.ts — 1 passed, compiled CLI/stdio MCP parity.
  • npm run verify:managed — passed, 11 portable conformance scenarios. Optional operator-local manifest and ILSpy oracle were not configured and remain explicitly unsupported in the report.
  • npm run check — passed; existing and reported lint warnings remain, no errors.
  • npm run docs:check — passed.
  • npm run verify:test-discovery — all 845 files discovered exactly once.
  • git diff --check — passed.
  • Local codex review --base origin/main with invocation-only compatibility overrides for two unsupported feature-table settings — completed with no actionable regressions reported. Its supplementary tests used the host-default Node 24.9.0; the authoritative test/gate results listed above were separately run on pinned Node 24.18.0.

Compatibility, safety, and release

  • Breaking changes/migration: none; callers receive corrected ownership for affected metadata.
  • Scope limits: this change does not add ParamPtr/EventPtr/PropertyPtr interpretation, fix the separate transient cursor-accounting issue, or introduce synchronous decoder cancellation.
  • Native/OS coverage: no Hopper/Ghidra/Android claims. Local public-boundary verification ran on Windows; no Linux/macOS run is claimed.
  • No binary fixture, local evidence log, credential or generated artifact is included.

Review checklist

  • One concrete defect, with the existing report and independent-fix scope linked.
  • Minimal owning-layer changes and Conventional Commit title.
  • Executed red/green, malformed-input, provenance and allocation-boundary checks.
  • Owning documentation and public CLI/MCP evidence included.
  • Final diff checked for unrelated changes and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T15:58:53.217159Z ccc72e5 PR opened
ℹ️ 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.

@morluto
morluto merged commit a95795c into morluto:main Oct 11, 2026
2 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 11, 2026
3 tasks done
@morluto

morluto commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Thanks, @chqcjq, for resolving FieldPtr and MethodPtr list positions back to physical member rows while keeping the original metadata tokens and partial facts intact. The independent PEReader comparison gives the pointer-table case a useful reference point. Welcome to REA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants