Skip to content

fix(managed): index attribute constructor owners once per layout - #1943

Merged
morluto merged 1 commit into
mainfrom
fix/issue-1940
Oct 11, 2026
Merged

morluto merged 1 commit into
mainfrom
fix/issue-1940

Conversation

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Fixes #1940

Behavior

inspect_managed_artifact resolved each local attribute constructor's declaring type by scanning the TypeDef table from row 1, so the work was O(attributes × TypeDefs). After #1897, repeated row cursors no longer charge the decode budget, so nothing bounded that work (raised as a P1 by Codex on #1897).

This PR builds a first-match owner index (methodOwnerRows) once per metadata layout and looks each constructor up in it. Already-owned method-list positions are skipped, so overlapping or unordered (malformed) method lists keep the previous first-match owner in near-linear time. Names are still read through readMetadataString per attribute, so the per-attribute representation charge is unchanged. The index arrays are reserved in the decode budget, and a build failure is cached like memberListRowLookup's.

16,000 TypeDefs × 16,000 attributes (584 KB) time
main d802304c5 38.1 s
this PR 27 ms

Open PR #1706 includes a similar index as part of a feature. That PR conflicts with main, predates pointer-table ownership (#1886), and still scans per attribute when method lists are unordered.

Validation

  • New module test in src/dotnet/ManagedArtifactInspector.test.ts. It fails on main (36.4 s against the 2 s bound) and passes here; all 170 src/dotnet tests pass.
  • npm run lint, npm run typecheck, npm run format:check: pass.
  • npm test: 8,261 passed, 12 failed. The same 12 failures occur on a clean origin/main worktree on this Mac. They are environmental: ibtool NIB tests (Command Line Tools only), the hdiutil verify refusal, and JS runtime discovery path tests in /private/var temp directories. None of them touch managed code.
  • Not verified against real compiled .NET assemblies; there is none on this machine.

🤖 Generated with Claude Code

Each CustomAttribute whose constructor is a local MethodDef scanned the
TypeDef table to find the declaring type, so inspect_managed_artifact did
O(attributes x types) row decoding. A 584 KB assembly with 16,000 types
and 16,000 such attributes blocked for about 38 s.

Build a first-match owner index once per metadata layout. Already-owned
list positions are skipped, so overlapping malformed method lists keep
their previous first-match owner in near-linear time. The index is
charged to the decode budget, and a build failure is cached like the
member pointer lookup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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-11T19:17:45.291742Z 060d3bb 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 c2cf7dc into main Oct 11, 2026
30 checks passed
@morluto
morluto deleted the fix/issue-1940 branch October 11, 2026 20:09
@github-actions github-actions Bot mentioned this pull request Oct 11, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 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.

inspect_managed_artifact rescans TypeDef rows for every local attribute constructor (quadratic)

2 participants