Skip to content

fix: bounds-check stats response (backend crash under pipelined load)#3

Merged
poly-glot merged 1 commit into
mainfrom
fix/handlestats-response-bounds
Jun 6, 2026
Merged

fix: bounds-check stats response (backend crash under pipelined load)#3
poly-glot merged 1 commit into
mainfrom
fix/handlestats-response-bounds

Conversation

@poly-glot

Copy link
Copy Markdown
Owner

Problem

100-VU cloud load crashed dmozdb (SIGABRT, index-out-of-bounds in binary_protocol.zig dispatchhandleStats), 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. handleStats is the only handler missing the resp.len bounds-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 test exit 0 in Linux + Zig 0.15.2 container (host gate is a known 0.13-vs-0.15 false-negative).
  • Will re-run the 100-VU cloud test post-deploy to confirm green.

…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
poly-glot force-pushed the fix/handlestats-response-bounds branch from 13e0574 to 1550799 Compare June 6, 2026 07:49
@poly-glot
poly-glot merged commit 085434f into main Jun 6, 2026
2 checks passed
@poly-glot
poly-glot deleted the fix/handlestats-response-bounds branch June 6, 2026 12:29
poly-glot added a commit that referenced this pull request Jun 7, 2026
fix: bounds-check stats response (backend crash under pipelined load)
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