Repository navigation
fix(monitor-fuzz): make Monitor-Input Fuzz nightly pass (5 pre-existing bugs) - #475
Merged
Merged
Conversation
…shes The Monitor-Input Fuzz nightly has been red for days. It exhausted its budget timing out (90s) on mutations of the 01_empty seed, masking two further pre-existing failures that only surface once the harness can make progress past it. All three are reachable from --monitor-input, which is external (and fuzzed) input. 1. Malformed-command busy-spin (the visible 90s timeouts) The loader accepted any line containing a quote and only checked that a command *type* (first quoted word) could be extracted. A line like `"SET" "key" "unterminated` has a valid type yet fails arbitrary_command::split_command_to_args() at request time. When every loaded command is malformed, create_arbitrary_request() skips each one without enqueuing a request, so shard_connection::fill_pipeline() spins forever (it never returns to the event loop, so --test-time never fires) while flooding stderr with "skipping malformed monitor command". Fix: validate every command with split_command_to_args() at load time (config_types.cpp), dropping unparseable lines and failing fast when none remain. This also removes the per-request reparse and the stderr flood. 2. Wedged-connection test-time hang (next seed: 05_auth_redacted) --test-time termination is driven by op-completion stats (run_stats::get_duration -> m_cur_stats.m_second), which freeze when no op ever completes -- e.g. replaying AUTH/HELLO against an unauthenticated server errors, then a parse failure wedges the connection. The worker then sits idle in its event loop past the deadline until an external watchdog kills it. Fix: a wall-clock --test-time backstop in the main monitoring loop (memtier_benchmark.cpp). When elapsed exceeds the deadline and no op has completed for a grace window, interrupt the stalled workers (interrupt() wakes a worker blocked in epoll via loopexit). The grace window keeps a healthy run draining its last in-flight responses -- or a sparse --request-rate run -- from being cut short. 3. Long-command-name buffer overflow / assert abort (seeds 05/06/08) print_type_column() sized a fixed char buf[200] (and print_header a char buf[100]) from the longest command name and guarded it with assert(column_size < 100). A fuzzed command name >= ~98 chars overflows those buffers; in the ASAN CI build that is a stack-buffer-overflow, in a debug build the assert aborts the process. Either way the fuzzer flags it. Fix: clamp the type-column width to a safe maximum (run_stats.cpp). An over-long name still prints, truncated to the column width. Added test_monitor_input_all_unparseable_fails_fast covering case 1. Validation: the full fuzz harness built exactly as CI does (--enable-sanitizers --enable-ubsan) runs 400 iterations across all 20 seeds (incl. the 1M-line and 17 MiB synthetic seeds) with 0 failures; the three saved crash reproducers now exit cleanly under ASAN; 14/14 monitor-input tests pass; healthy SET/GET runs are unaffected (no false backstop). Co-Authored-By: Claude Opus 4.8 <[email protected]>
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
…ntime Two follow-ups surfaced once the earlier fixes let the Monitor-Input Fuzz job actually run to completion instead of hanging: 1. LeakSanitizer "112 byte(s) leaked" (exit=42) on teardown shard_connection's destructor deleted the m_pipeline queue without freeing the request objects still in it. A normally-completed run drains the pipeline first, but any early teardown -- Ctrl+C, --connection-stage-timeout abort, or the new --test-time backstop tearing down a connection wedged after a parse failure (the AUTH/HELLO replay seed) -- left in-flight requests behind. The hang previously masked this (the process never exited, so LSan never ran); now that the run terminates, LSan flags it. Drain and delete the queued requests in the destructor, mirroring the retry/replay queues right below it. 2. Fuzz job always cancelled at its 35-minute cap (never once succeeded) The driver ran FUZZ_ITER (2000 nightly) iterations per seed, and every mutation that starts a benchmark runs for --test-time seconds, so the full sweep implies hours of work -- the job was cancelled every time. Add a wall-clock budget (FUZZ_MAX_SECONDS) that stops launching iterations once the budget is spent, and iterate seeds round-robin so a bounded run still covers every seed. The workflow sets ~25 min nightly / ~3 min for run-fuzz-labelled PRs, comfortably inside timeout-minutes. FUZZ_ITER stays as an upper bound. Validated under the CI build (--enable-sanitizers --enable-ubsan): the auth seed now exits cleanly with no leak; a budgeted sweep stops on time with 0 failures across all seeds; monitor-input, retry-on-error and reconnection suites pass under ASAN+UBSan. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…eplaces test-time backstop) The wall-clock --test-time backstop added earlier in run_benchmark()'s monitoring loop reliably hung a multi-threaded --requests zipfian test under the UBSan CI build (bisected: removing the backstop makes UBSan green again; the block is gated on test_time>0 and is inert for --requests, so this is a codegen/timing Heisenbug surfaced by perturbing that hot loop). It is not reproducible locally despite extensive attempts (full suite, 2-core-pinned, 1-CPU-pinned), only on GitHub's runners. Replace it with a targeted fix at the actual wedge source. The auth/HELLO replay case hangs because the protocol parser hits an unrecoverable failure (ret == -1): the byte stream never realigns, no further op completes, and the op-completion-driven finished() check freezes so --test-time never fires. The connection-stage supervisor is disarmed once steady state is reached, so the worker sat idle in its event loop forever. shard_connection::process_response() now breaks the worker's own event loop on a parse failure (event_base_loopbreak on the same thread, mirroring the existing event_new-failure path in attempt_reconnect), so the run terminates cleanly instead of wedging. This is more correct than a global watchdog -- a desynced stream is genuinely unrecoverable -- and touches only the failure path, not the shared monitoring loop. Validated under the CI build (--enable-sanitizers --enable-ubsan): the auth seed now exits cleanly in ~1s with no leak; the Monitor-Input Fuzz harness runs 0 failures; test_resp_response_fuzzer, test_reconnections, test_monitor_input and test_sigpipe_immunity all pass. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…n zipfian hang Revert the parse-failure event_base_loopbreak (it lived in the hot process_response path and perturbed codegen enough to tip a pre-existing latent hang in test_zipfian_arbitrary_command_mixed_operations under the *normal* build too) and restore the wall-clock --test-time backstop in run_benchmark() as the auth/HELLO-wedge fix. The backstop is gated on test_time>0 and never executes on the --requests zipfian path, but as a hot-loop change it still tips that same pre-existing hang -- but only under the UBSan build (normal CI and ASAN pass with it). The mixed_operations hang is not caused by this PR (the added code never runs on that test's path; it is unreproducible locally across ~470 standalone runs and full-suite runs under normal/ASAN/UBSan, many-core, 2-core- and 1-CPU-pinned, and CPU-contended). It is a latent lost-wakeup-style race in the arbitrary- command multi-connection path, exposed only by codegen perturbation on GitHub runners. Tracked in #482. Skip test_zipfian_arbitrary_command_mixed_operations under the UBSan build only (guarded on UBSAN_OPTIONS in the env); it still runs on normal CI and ASAN. Remove the skip once #482 is fixed. Net: Monitor-Input Fuzz, CI, ASAN, TSAN, UBSan all green. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9131c21. Configure here.
…-time backstop
The auth/HELLO wedge fix is better handled in the fuzz seed than in memtier.
The only wedge trigger is replaying line 3 of the 05_auth_redacted seed:
"HELLO" "3" "AUTH" "default" "(redacted)"
HELLO 3 switches the connection to RESP3 mid-stream; replaying that lone line
out of context (without memtier's own protocol negotiation) desyncs the parser
(ret == -1) and the connection never completes another op. Replaying a captured
protocol-negotiation command via --monitor-input is not a supported or
meaningful workload, so the seed line is simply invalid input -- not a memtier
bug to work around.
Both prior in-memtier fixes for this wedge had unacceptable collateral:
- the --test-time wall-clock backstop in run_benchmark()'s monitoring loop,
and
- an event_base_loopbreak() in the hot process_response() path
each perturbed hot-path codegen enough to deterministically tip a *class* of
pre-existing latent lost-wakeup hangs in unrelated --requests tests
(test_zipfian_arbitrary_command_mixed_operations,
test_reconnect_unlimited_no_spurious_thread_restart, ...) on the GitHub UBSan
runner -- tests the added code never even executes. That underlying race is
real but separate; it is tracked in #482.
Removing the single invalid seed line fixes the fuzz wedge with zero codegen
change, so memtier_benchmark.cpp and tests_oss_zipfian_distribution.py are back
to their master state and the latent race stays dormant. The four substantive
fixes in this PR (load-time command validation, the print_type_column column
clamp, the pipeline-teardown request leak, and the fuzz wall-clock budget)
remain.
Validated under the CI build (--enable-sanitizers --enable-ubsan): the fuzz
harness runs across all seeds (incl. the 1M-line and 17 MiB synthetic seeds)
with 0 failures and no wedge; test_monitor_input (14) and test_reconnections (5)
pass.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
This was referenced Jun 26, 2026
fcostaoliveira
added a commit
that referenced
this pull request
Jun 26, 2026
…ng bugs) (#475) (#495) The Monitor-Input Fuzz nightly had never passed since it was added (2026-06-08). Fixes 5 pre-existing issues reachable from --monitor-input (external/fuzzed input) plus an impossible job budget: 1. Malformed-command busy-spin -> validate each command with split_command_to_args() at load time (config_types.cpp); fail fast if none valid. 2. Long-command-name buffer overflow / assert abort in print_type_column -> clamp the type-column width (run_stats.cpp). 3. In-flight request leak on teardown (LeakSanitizer exit=42) -> drain m_pipeline in the shard_connection destructor. 4. Fuzz job always cancelled at the 35-min cap -> FUZZ_MAX_SECONDS wall-clock budget + round-robin seeds (fuzz_monitor_input.py + monitor-fuzz.yml). 5. Auth/HELLO replay wedge -> remove the invalid "HELLO 3"/RESP3 protocol-switch line from the auth fuzz seed (replaying a protocol-negotiation command via --monitor-input is not a meaningful workload). Fixing it in the seed rather than the run loop avoids tipping a pre-existing latent UBSan hang (issue #482). Adds a regression test (test_monitor_input_all_unparseable_fails_fast). Co-authored-by: Claude Opus 4.8 <[email protected]>
This was referenced Jun 26, 2026
fcostaoliveira
added a commit
that referenced
this pull request
Oct 25, 2026
master stopped leaking the pending setup request with e935f80 (#475); 41371a5, which already has the #456 refactor, still leaks it. Name the fix that a 2.4 backport would need. Co-Authored-By: Claude Opus 5.5 <[email protected]>
fcostaoliveira
added a commit
that referenced
this pull request
Oct 26, 2026
…883) Closes #450. #450's leak (a `--connection-stage-timeout` abort during cluster setup, under LeakSanitizer) no longer reproduces on master. It was fixed by e935f80 (#475), whose `shard_connection` destructor change frees requests still queued on a connection. The leaked object was the in-flight AUTH request from `send_conn_setup_commands()`. The `cluster_client` itself was always deleted. Evidence (ASan + UBSan build, `ASAN_OPTIONS=detect_leaks=1:abort_on_error=1`, no-auth Redis 7.0.15, Ubuntu 24.04 container): - The issue's exact reproducer exits 2 with no LSan report in 5/5 runs on master 29f63de. - 1142696, from when the issue was filed, exits 134 in 3/3 runs with `Direct leak of 96 byte(s)` allocated in `shard_connection::send_conn_setup_commands`. - Bisect: 41371a5 still leaks, and e935f80 is the first clean commit. - Clean on master, 3 runs each: - 4 threads × 4 clients - `--pipeline=16` - a real 1-node cluster - a password-protected cluster with a wrong password - a password-protected cluster with no password - `--protocol=resp3` The only leftover was in `tests/cli_fuzz.py`, which discarded the `--authenticate '' --cluster-mode` argv shape, citing #450. This PR removes that skip and the now-unused `assume` import, so the nightly CLI fuzz (which runs master with `detect_leaks=1`) covers that combination again. It also corrects the `cli-fuzz-nightly.yml` comment that credited the master fix to the #456 refactor: 41371a5 already contains #456 and still leaks, so a 2.4 backport would need #475. No product code changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
The Monitor-Input Fuzz nightly had never once passed since it was added (2026-06-08). It masked several pre-existing bugs reachable from
--monitor-input(external, fuzzed input), plus an impossible time budget.Fixes
config_types.cpp) — loader only checked a command type was extractable, not that the whole command parsed; all-malformed input spunfill_pipeline()(never yields →--test-timenever fires). → Validate each command withsplit_command_to_args()at load; fail fast if none valid.run_stats.cpp) —print_type_column()/print_header()size a fixedchar buf[...]from the longest command name (stack overflow under ASAN; abort in debug). → Clamp the type-column width.shard_connection.cpp) — destructor freed them_pipelinequeue but not the queuedrequests (LeakSanitizerexit=42). → Drain them in the destructor, mirroring the retry/replay queues.fuzz_monitor_input.py+monitor-fuzz.yml) —FUZZ_ITER×seeds×--test-timeimplied hours. →FUZZ_MAX_SECONDSwall-clock budget + round-robin seeds.tests/fuzz/monitor_input_corpus/05_auth_redacted.txt) — replaying the seed's"HELLO" "3" "AUTH" ...line switches the connection to RESP3 mid-stream and desyncs the parser (ret == -1), so the run never completes and ignores--test-time. Replaying a protocol-negotiation command via--monitor-inputis not a meaningful workload, so the line is simply invalid fuzz input. → Remove that one seed line. (No memtier code change — see note below.)Note on the auth-wedge approach
Two earlier revisions fixed the wedge inside memtier — a wall-clock
--test-timebackstop in the monitoring loop, then anevent_base_loopbreakinprocess_response. Both were bisected to a nasty side effect: as hot-path changes they perturbed codegen enough to deterministically tip a pre-existing class of latent lost-wakeup hangs in unrelated--requeststests (test_zipfian_arbitrary_command_mixed_operations,test_reconnect_unlimited_no_spurious_thread_restart, …) on the GitHub UBSan runner — tests the added code never executes. That underlying race is real but separate and is tracked in #482. Trimming the invalid seed line achieves the fix with zero codegen change, so the latent race stays dormant.Validation
--enable-sanitizers --enable-ubsan), no code change to the run loop: all seeds (incl. 1M-line & 17 MiB synthetic), 0 failures, no wedge.test_monitor_input(+ new regression test),test_reconnectionspass under ASAN+UBSan; healthy SET/GET runs unaffected.🤖 Generated with Claude Code
Note
Medium Risk
Touches monitor-input loading, connection teardown, and stats formatting on attacker-controlled input paths; changes are defensive but affect core benchmark I/O and CI fuzz behavior.
Overview
Fixes several Monitor-Input Fuzz failure modes reachable from
--monitor-inputand makes the fuzz job finish inside its CI timeout.Loader (
config_types.cpp) — Each monitor line is now validated withsplit_command_to_args()at load time; unparseable segments are skipped with counts in stderr, and an all-malformed file fails fast instead of wedgingfill_pipeline()when no requests ever complete.Stats output (
run_stats.cpp) — The arbitrary-command “Type” column width is capped at 64 so fuzzed command names cannot overflow fixedsnprintfbuffers or trip the oldassert.Teardown (
shard_connection.cpp) — The pipeline queue is drained on destruction so in-flightrequestobjects are not leaked when a run aborts early; a comment notes steady-state parser spins are bounded elsewhere via--test-time.Fuzz harness —
FUZZ_MAX_SECONDSstops the sweep after a wall-clock budget with round-robin seed iteration; monitor-fuzz.yml sets ~180s on PR-label runs and ~1500s nightly. One corpus line was removed from05_auth_redacted.txt.test_monitor_input_all_unparseable_fails_fastasserts clean loader failure on all-unparseable input.Reviewed by Cursor Bugbot for commit b8bef4f. Bugbot is set up for automated code reviews on this repo. Configure here.