fix(interp): add fast pre-check for heredoc size limit#185
Merged
Conversation
For regular << heredocs, expandWord() on the full content is expensive under the race detector, causing TestPentestHeredocSizeLimitRegular to exceed its 5s timeout in CI. Add hdocWordRawSize() to compute the raw literal byte count before expansion — if it already exceeds MaxHeredocBytes, reject immediately without expanding. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
astuyve
approved these changes
Apr 16, 2026
The 5-second context was created before parsing, so parsing a 10 MiB heredoc under the race detector consumed the entire timeout before execution could start. Move parsing into pentestRedirRun before the context is created, so the timeout only covers execution. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
TestPentestHeredocSizeLimitRegularCI flake — for regular<<heredocs,expandWord()on 10 MiB of content is slow enough under the race detector to exceed the test's 5-second context timeout, producing empty stderr instead of the expected "exceeds maximum size" error.hdocWordRawSize()pre-check — computes the total byte count of literal parts in the parsed heredoc word (O(n), no allocation). If the raw literals already exceedMaxHeredocBytes, the heredoc is rejected immediately before the expensive expansion pass.<<-variant was unaffected because it already checks size incrementally per-line.Test plan
TestPentestHeredocSizeLimitRegularpasses locally (was timing out in CI)TestPentestHeredocSizeLimitDashstill passesTestPentestHeredocSizeLimitUnderLimitstill passes (heredoc just under limit succeeds)interp/testspass with-race-race🤖 Generated with Claude Code