Skip to content

Charge lexer attributes to the shared memory budget - #343

Open
edevil wants to merge 1 commit into
cloudflare:mainfrom
edevil:fix/lexer-attribute-memory-budget
Open

edevil wants to merge 1 commit into
cloudflare:mainfrom
edevil:fix/lexer-attribute-memory-budget

Conversation

@edevil

@edevil edevil commented Oct 20, 2026

Copy link
Copy Markdown

Charge lexer attribute-outline capacity to the existing shared memory limit before growing the buffer. This metadata previously used an unaccounted Vec, allowing attribute-heavy tags to bypass the configured limit.

Reuse LimitedVec, propagate the existing memory error through attribute-completion actions, and release failed growth charges and completed-token capacity.

Behavior change: sufficiently attribute-heavy tags can now return MemoryLimitExceeded where they previously exceeded the configured budget unnoticed. No new public options or attribute stripping; graceful bailout retains its existing raw-output behavior.

  • Cover duplicate/unique attributes, input framing, shared raw-buffer accounting, bailout, and charge lifetime. Raise only the conformance harness's test budget for newly counted metadata.
  • Validation: standalone Rust tests with _integration_test (including HTML5lib fixtures), doctests, strict all-targets Clippy, and formatting pass. The shared-budget fixture is also checked on wasm32.

Attribute outlines used an unbounded Vec, allowing a short boolean-attribute tag to allocate tens of MiB despite the rewriter memory limit.

Use LimitedVec and propagate growth failures through tokenizer actions. Roll back failed charges and release capacity when tokens are emitted or dropped.

Attribute-heavy pages can now fail with MemoryLimitExceeded rather than bypass the configured limit. Add framing, bailout and charge-lifetime regressions; give token-conformance fixtures room for the newly counted metadata.
@edevil
edevil requested review from a team, Noah-Kennedy, jasnell and orium as code owners October 20, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant