Skip to content

fix(managed): bound transient CIL by decoded instruction count - #1822

Merged
morluto merged 1 commit into
morluto:mainfrom
jhuang-tw:fix/managed-single-method-budget
Oct 11, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
jhuang-tw:fix/managed-single-method-budget

Conversation

@jhuang-tw

Copy link
Copy Markdown
Contributor

Why this needs a separate follow-up

Merged #1768 correctly separates accumulated per-method decoding reservations from the retained-output budget. One remaining false rejection is still reproducible on its merged main: a single method with more than ~256 KiB of multi-byte CIL is rejected by admitTransient(il.length * 256) before its actual instruction count is known, even when its retained result is modest.

On pristine post-#1768 main f178bf1c, a source-owned 272,896-byte PE/CLI fixture with one 270,000-byte method (54,000 five-byte instructions) returned coverage: unavailable, types: [], methods: [], metadata.representation resource-limit. The failure is not a malformed target or an MCP transport loss.

Fix

  • Admit 256 conservative transient bytes per actually decoded instruction, after checking the opcode/operand boundaries and before growing the instruction and start-index arrays. Multi-byte operands no longer each cost a complete instruction's reservation.
  • Propagate ManagedReaderFailure out of the decoder so exhausted budget stays a typed resource-limit, never a misleading malformed-IL observation.
  • Keep the existing 64 MiB shared retained/transient admission, per-item retained-output charging, exception-section coexistence, canonical Evidence, and all default CLI/MCP result contracts unchanged. No arbitrary heap/budget increase or target execution.

Independent acceptance and regression

  • Source-owned well-formed CIL: 54,000 five-byte zero-displacement br instructions (each branch targets the following instruction), followed by ret. Exactly 270,001 IL bytes, stack-neutral. 54,001 instructions are reported with coverage: complete, one retained type and method.
  • Dense single-byte nop instructions with trailing ret still produce a typed resource-limit and a recorded positive offending IL byte offset, with no invented partial successful method.
  • Focused managed + budget regressions: 31/31 PASS. Expanded src/dotnet, managed provider/MCP and CLI acceptance suites: PASS. npm run check:fast, npm run build:cached, npm run docs:check, and oxfmt --check on all three changed files: PASS.
  • Actual published CLI command and pinned-SDK stdio MCP on the generated PE (target statically analyzed, never executed): CLI JSON 4,172,415 bytes, MCP result 9,101,708 bytes under ordinary framing, exact deep equality of their complete normalized_result, 54,001 decoded instructions, successful following SDK ping, and unchanged artifact SHA-256 ab80b511d759b6ec82b20e4ff7f6c4a83c8a5f663d0a7f0ea9049be1ae656d00. Temporary fixtures cleaned.
  • Zenu mutation checks: VERIFIED including affected-file identity.

Scope and risks

Follow-up to #1768, refs #1801; does not claim to close #1801 or address large signature-only budgets, independent caller-selected resource overrides, or very large retained projections. Another contributor has discussed a different per-call 1 GiB expansion budget in #1801; this intentionally preserves the original 64 MiB transient admission and charges what the decoder actually produces. The 256-byte per decoded instruction accounting remains a conservative projection, not a measured peak-process-RSS guarantee.

Verification used Windows Node 24.17.0/npm 10.9.2 rather than repository-preferred Node 24.18.0/npm 11.16.0; no real proprietary managed assembly, Ghidra or Hopper claim is made.

The change is scoped to three source/test files, with no generated artifacts, user-owned project changes, or new dependencies.

AI assistance was used to develop and verify this contribution.

@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-11T13:05:48.295276Z 46104eb 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 554cb45 into morluto:main Oct 11, 2026
31 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 for the follow-up to #1768, @jhuang-tw. Charging transient CIL by decoded instruction instead of raw byte lets a 270 KB method with wide operands pass when its retained facts fit, while a truly over-budget stream still returns a typed resource-limit. The CLI and stdio MCP parity check covers the public boundary.

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

Labels

area: build Build, CI, packaging, and publishing bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Managed static provider rejects game-sized assemblies: 256x per-byte IL/blob charge exhausts the 64 MiB budget at ~256 KB of IL

2 participants