Repository navigation
fix(opts): reject negative -c/-t/-n/--test-time; guard Hits/sec from /0 - #436
Conversation
Same crash class as merged phases redis#428/redis#429 (--pipeline, --data-size, --run-count): strtoul("-1") wraps to UINT_MAX and -c -1 then tries to spawn ~4B clients. The four count flags missed the phase-2 sweep. Also adds a > 0 guard to run_stats.cpp summarize() for the legacy GET Hits/sec / Misses/sec computation (the only summarize site without one); sub-microsecond runs were emitting +Inf / nan into the JSON. Refs: 2.4 review findings redis#24 + redis#19 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…ize error wording Reviewers R3+R4 flagged that the prior commit only guarded m_hits_sec and m_misses_sec in summarize(); six sibling rate computations (m_ops_sec, m_bytes_sec, m_bytes_sec_rx, m_bytes_sec_tx, m_moved_sec, m_ask_sec, m_connection_errors_sec) still divided by test_duration_usec with no guard. All now use the (test_duration_usec > 0 ? ... : 0.0) ternary, consistent with sites at lines 1300, 1311, 1317, 1344, 1354, 1360, 1627, 1629. R5 also flagged that the four new error messages mixed "must be a positive integer" and "must be greater than zero". Standardized to match the phase-2 convention. Refs: 2.4 review of PR redis#436 (R3/R4/R5). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
R3+R4+R5 findings addressed in 2b95d26: /0 guard extended to all 8 summarize() rate computations; error wording standardized to phase-2 convention. |
Resolve conflicts after redis#432/redis#434/redis#435 landed on master. Conflict in memtier_benchmark.cpp: adopt master's "must be a positive integer" wording (standardized by redis#432) for the four negative-value guard fprintf() calls added by this branch; both sides trigger on the same code path and the test assertions only check the prefix, so either wording is functionally correct.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 8e8bd23. Configure here.
| result.m_wait_cmd.summarize(totals.m_wait_cmd, test_duration_usec); | ||
| result.m_ar_commands.summarize(totals.m_ar_commands, test_duration_usec); | ||
|
|
||
| // Guard against zero-duration runs (sub-microsecond or Ctrl-C at startup) which would produce +Inf/nan in the JSON. |
There was a problem hiding this comment.
Divide-by-zero guard incomplete in summarize calls
Medium Severity
The new divide-by-zero guard at line 1007 only protects the inline rate computations below it, but totals_cmd::summarize() (called at lines 1002–1005) still divides by test_duration_usec six times without any guard. In a zero-duration run, these calls produce +Inf/NaN for per-command m_ops_sec, m_bytes_sec, m_bytes_sec_rx, m_bytes_sec_tx, m_moved_sec, and m_ask_sec — the same class of bug the PR intends to fix.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 8e8bd23. Configure here.


Summary
Two small hygiene fixes flagged in the 2.4 release-readiness review.
1. Reject negative
-c/-t/-n/--test-time(memtier_benchmark.cpp)The merged phase-2 sweep (#428/#429) added
optarg_is_negative+errno=ERANGEguards to--pipeline,--data-size,--run-countetc., but missed the four older count flags.-c -1→strtoulwraps →(unsigned int)UINT_MAX = 4294967295→ ~4 billion clients spawned. Same crash class.Adds the existing pattern to all four cases. Preserves the
-n allkeyssentinel.2. Guard
Hits/secfrom divide-by-zero (run_stats.cpp:1008-1009)The legacy GET path's
summarize()was the lone holdout missing atest_duration_usec > 0guard. Sub-microsecond runs (or Ctrl-C at startup) produced+Inf/nanin the JSON. Adds the guard; matches the pattern every other 2.4 hits/sec computation already uses.Test plan
-c -1,-c 0,-t -1,-t 0,-n -2,-n 0,--test-time -1,--test-time 0Note
Low Risk
Localized input validation and defensive math in stats reporting; no auth, networking protocol, or persistence changes.
Overview
Hardens CLI parsing for
-c,-t,-n, and--test-timeso negative or zero values fail at startup with a clear stderr message instead ofstrtoulwrapping to huge counts and OOM (same pattern as earlier fixes for--pipeline/--data-size/--run-count). A newtests/test_cli_validation_count_flags.pyexercises those rejections without Redis.In
run_stats::summarize, all per-second rates that divide bytest_duration_usec(hits/misses, ops, KB/s, MOVED/ASK, connection errors) now return 0.0 when duration is zero, avoiding+Inf/nanin JSON on sub-microsecond runs or immediate interrupt.Reviewed by Cursor Bugbot for commit 8e8bd23. Bugbot is set up for automated code reviews on this repo. Configure here.