Skip to content

fix(hookvm): charge range iterations against the memory budget - #464

Merged
BaaRai merged 2 commits into
BaaRai:mainfrom
Coff0xc:fix/hook-range-budget
Nov 22, 2026
Merged

BaaRai merged 2 commits into
BaaRai:mainfrom
Coff0xc:fix/hook-range-budget

Conversation

@Coff0xc

@Coff0xc Coff0xc commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Ranging over a request body built one element per byte without charging MaxMemory. range now charges length times 16 before the loop and stops with ErrMemoryLimit. go test ./traffic/hookvm/ -run TestResourceBoundsMemoryStepTimeoutPanicAndRegexp/range_over_body_stopped_by_memory_budget passes.

Ranging over a body or collection built the iteration list without calling
alloc, so a large body bypassed MaxMemory. The length is charged before the
loop, and the run stops with ErrMemoryLimit when it does not fit.
Copilot AI balanced review requested due to automatic review settings November 21, 2026 19:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@BaaRai
BaaRai merged commit 3ca8f21 into BaaRai:main Nov 22, 2026
5 checks passed
@BaaRai

BaaRai commented Nov 22, 2026

Copy link
Copy Markdown
Owner

Thanks @Coff0xc, merged. Every range form now charges the iteration before the loop, so a large body stops at the hook memory budget instead of allocating element by element. The merge commit only brings the branch onto main.

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.

3 participants