fix: bounds-check stats response (backend crash under pipelined load)#3
Merged
Merged
Conversation
…t overflow the buffer handleStats was the one response handler missing the resp.len guard its siblings all have. Responses are pipelined into a fixed 256KB per-connection buffer; under heavy concurrency the buffer fills, and a stats reply landing in a near-full tail wrote six u64s past the slice end → panic (SIGABRT) → reactor thread abort → pod restart. Surfaced by a 100-VU cloud load test once the backend (post web/backend split) actually handled that concurrency. Guard the write and return an error frame when the remaining space is too small, matching every other handler. Regression test locks the invariant.
poly-glot
force-pushed
the
fix/handlestats-response-bounds
branch
from
June 6, 2026 07:49
13e0574 to
1550799
Compare
poly-glot
added a commit
that referenced
this pull request
Jun 7, 2026
fix: bounds-check stats response (backend crash under pipelined load)
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.
Problem
100-VU cloud load crashed
dmozdb(SIGABRT, index-out-of-bounds inbinary_protocol.zigdispatch→handleStats), crash-looping the backend; the cloud k6 run failed its thresholds. The earlier local 100-VU run missed it (less request pipelining).Root cause
Responses are pipelined into a fixed 256KB per-connection buffer.
handleStatsis the only handler missing theresp.lenbounds-check its siblings have, so when a stats reply lands in a near-full buffer tail it writes 6×u64 past the slice → panic → reactor thread abort → pod restart. Pre-existing latent bug; exposed (not caused) by the web/backend split now that the backend handles real 100-VU concurrency.Fix
Guard the write; return an error frame when remaining space is insufficient, matching every other handler. Regression test (
handleStats refuses an undersized response buffer instead of overflowing it) locks the invariant.Verified
zig build testexit 0 in Linux + Zig 0.15.2 container (host gate is a known 0.13-vs-0.15 false-negative).