Repository navigation
fix(managed): honor metadata ExtraData before table decoding - #1893
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…extra-data # Conflicts: # docs/managed-code-analysis.md
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Honor the CLR metadata tables
ExtraDataflag before decoding table rows. The parser now checks and skips the fixed four-byte word after all row counts, rather than interpreting it as the beginning of the first metadata row.No existing issue is linked: this was found while auditing table-header decoding, and searches for
ExtraData,heapSizesand the specific header behavior found no matching issue or PR before submission.Problem and expected behavior
When
HeapSizes & 0x40is set, Microsoft readers consume an extra four-byte word after the row counts. The compatibility extension is used by some obfuscators; it is not specified by ECMA-335. See System.Reflection.Metadata's reader and the CLR native implementation.On base
29d2624b, REA begins decoding tables four bytes too early. A 4 KiB source-owned PE fixture with the extension reports invalid heap/blob indexes and loses usable metadata, while the ordinary fixture succeeds. MicrosoftPEReader/MetadataReaderindependently reads both fixtures as the same module (Fixture.dll), assembly (Fixture.Managed), MVID, type and method.Expected: align the table data correctly regardless of whether the word is zero, nonzero or
0xffffffff. Its value is opaque, not a length. An incomplete word must produce a typed coverage failure at the expected file location without borrowing bytes from adjacent heaps.Change and scope
invalid-metadata-root / metadata.tables-extra-datafor a truncated word, with an absolute file offset.Contract and boundary impact
ManagedMetadataLayouttables-header interpretation.Evidence and regression coverage
0x40, a#-stream, row-count truncation, and ExtraData extents of 0/1/3 bytes with absolute-offset assertions.For evidence-bearing changes:
Validation performed
On Windows x64, pinned Node 24.18.0 / npm 11.16.0:
npm run test:local -- <all 9 src/dotnet/*.test.ts files>— 147 passed, no failures or skips.npm run test:focused -- tests/acceptance/managedMetadataExtraData.test.ts— 1 passed, compiled CLI/stdio MCP parity.npm run verify:managed— passed, 11 portable conformance scenarios; optional operator-local manifest/ILSpy checks remain unconfigured.npm run check— passed; reported lint warnings remain, no errors.npm run docs:check— passed.npm run verify:test-discovery— 844 test files, each discovered exactly once.git diff --check— passed.codex review --base origin/main, with invocation-only compatibility overrides for two legacy CLI feature settings — completed with no actionable regressions reported. It also reran 103 focused source tests and the compiled acceptance test; the full 147-test result above was run separately.Compatibility, safety, and release
#JTD, or deleted-token semantics associated with other metadata flags.Review checklist