Repository navigation
Reject wrapped, overflowing and empty values on the remaining numeric options (#725) - #748
Conversation
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this. I went through most of it and only have a few comments.
The The code looks solid to me. I'd mainly want the description/release note updated for the (would file this as a comment, not a formal block) |
86b872f to
87f814f
Compare
…igned errno Review of #748: - --rate-limiting above UINT_MAX - 49 made (request_rate + 49) / 50 wrap to 0 and request_rate / 0 raise SIGFPE. The PR advertises UINT_MAX as valid, so do the rounding in 64 bits. - A --thread-conn-start-*-jitter-micros range of UINT_MAX made jitter_range + 1 wrap to 0 and rand() % 0 raise SIGFPE. Same fix. - The errno-leak test now also runs --max-retries after the stale ERANGE; removing errno = 0 from parse_signed() fails it. - C leaves ERANGE for a subnormal strtod() result implementation-defined, so the guard now checks, through ctypes, that this libc sets it for 1e-310. 1e999 (where ERANGE is required) was not used because --key-median accepting inf is itself a bug that will be fixed. - Messages for --replica-clients/--replicas-per-shard drop the "--" prefix, like the other options. - README: "-0" is now rejected on the options where 0 is valid. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks. Both points are addressed in 87f814f. Errno source. You're right: C leaves I didn't switch to
The same push also fixes two SIGFPEs at the newly advertised maxima. Both also happen on master:
Both now do that math in 64 bits, and there are regression tests for each. 🤖 Generated with Claude Code |
|
Both are addressed in 183f9d6.
I capped it at
🤖 Generated with Claude Code |
…et at their real bounds Review of #748: - --key-maximum=18446744073709551615 with the default --key-minimum 0 is a full 64-bit range. random_range() computed rn % (max - min + 1), which wraps to % 0 (SIGFPE with R:R), and gaussian_distribution_range() rejected every sample against max + 1 == 0, so G:G hung (it ignores SIGTERM). Treat a wrapped span as "any rn", compare against max + 1 in double, and clamp the result so a double >= 2^64 is never converted. Sequential and parallel patterns were checked and do not wrap. - --multi-key-get is capped at 16777214, the largest value for which keylist's unsigned 256 * (N + 1) buffer size does not wrap, instead of 1000000: values that used to work keep working (#212). --help and the man page note the ~272 bytes per key per client. - --data-offset is capped at (1 << 29) - 1 in the parser, so its "must be <= N" is true; the later "data-offset too long" check in main() is gone. - --rate-limiting errors say "rate-limiting must be ...". - README: the message change for --pipeline, -d and --reconnect-interval. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks. Answers to the three points, all in 8301d5a. 1.
I made the arithmetic safe instead of capping the range:
2. 3. Helper refactor. I left it out on purpose. The block is three lines per option, and keeping each option's error call next to its own bound makes the diff easy to check one option at a time. I'm happy to fold it in if a maintainer prefers. Also in this push:
🤖 Generated with Claude Code |
…igned errno Review of #748: - --rate-limiting above UINT_MAX - 49 made (request_rate + 49) / 50 wrap to 0 and request_rate / 0 raise SIGFPE. The PR advertises UINT_MAX as valid, so do the rounding in 64 bits. - A --thread-conn-start-*-jitter-micros range of UINT_MAX made jitter_range + 1 wrap to 0 and rand() % 0 raise SIGFPE. Same fix. - The errno-leak test now also runs --max-retries after the stale ERANGE; removing errno = 0 from parse_signed() fails it. - C leaves ERANGE for a subnormal strtod() result implementation-defined, so the guard now checks, through ctypes, that this libc sets it for 1e-310. 1e999 (where ERANGE is required) was not used because --key-median accepting inf is itself a bug that will be fixed. - Messages for --replica-clients/--replicas-per-shard drop the "--" prefix, like the other options. - README: "-0" is now rejected on the options where 0 is valid. Co-Authored-By: Claude Opus 5.5 <[email protected]>
e7f852c to
17b7081
Compare
…et at their real bounds Review of #748: - --key-maximum=18446744073709551615 with the default --key-minimum 0 is a full 64-bit range. random_range() computed rn % (max - min + 1), which wraps to % 0 (SIGFPE with R:R), and gaussian_distribution_range() rejected every sample against max + 1 == 0, so G:G hung (it ignores SIGTERM). Treat a wrapped span as "any rn", compare against max + 1 in double, and clamp the result so a double >= 2^64 is never converted. Sequential and parallel patterns were checked and do not wrap. - --multi-key-get is capped at 16777214, the largest value for which keylist's unsigned 256 * (N + 1) buffer size does not wrap, instead of 1000000: values that used to work keep working (#212). --help and the man page note the ~272 bytes per key per client. - --data-offset is capped at (1 << 29) - 1 in the parser, so its "must be <= N" is true; the later "data-offset too long" check in main() is gone. - --rate-limiting errors say "rate-limiting must be ...". - README: the message change for --pipeline, -d and --reconnect-interval. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review of #748: - keylist::add_key() doubled an unsigned int buffer size, which wraps to 0 past 2 GiB and spins the growth loop forever. With the --multi-key-get cap at 16777214 that is reachable, e.g. --multi-key-get=8388607 with ~260-byte keys. The buffer size is now size_t and grows through keylist_grow_size(), which stops doubling before size_t overflows. tests/unit/keylist_growth_test.cpp covers the 2^31 step and the SIZE_MAX edge without allocating; a real run would need several GB per client. The cap comment and release note now say exactly what 16777214 guarantees: the preallocated buffer stays below 4 GiB. - Zipf samples are clamped to the range maximum, as Gaussian ones are: at --key-maximum=ULLONG_MAX a sample can be the double 2^64, whose conversion to unsigned long long is undefined. The full-range run test now also covers Z:Z. - random_range() documents that get_random() yields 62 bits, so spans above 2^62 are not uniform (unchanged behaviour). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Replying point by point to the review. Everything is in 17b7081, and the branch is rebased on a7881e0. 1. Zipf with the full 64-bit range. Yes, the same undefined conversion applied there. Every Zipf sample now goes through 2. 3. Empty
4. Authorship. Fixed. Those commits came from a stray local git identity. I rewrote the branch so every commit's author and committer is 5. Message change for The same push also fixes a hang the
🤖 Generated with Claude Code |
…not grow Review of #748: - Reverting keylist::m_buffer_size to unsigned int passed every test, so a static_assert in keylist now requires it to be at least size_t wide; the helper's unit test only covers the growth arithmetic. - A failed malloc/realloc of the MGET key list (GBs with a large --multi-key-get and long keys) prints "out of memory building MGET key list" and exits 1 instead of asserting. - The --multi-key-get cap comment says what it is now: a memory sanity limit that keeps the preallocated key buffer under 4 GiB. - The JSON configuration also records scan_incremental_max_iterations, like --show-config. - Test docstrings: the Z:Z case only checks that the full range runs (its clamp is defensive), and the jitter test passes on the timeout. Blank lines fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for the re-review. Everything is in 9d17d4c. Correction to my last reply. I said that keeping the size in
Also in this push:
🤖 Generated with Claude Code |
… options #721 moved 13 options onto parse_unsigned(), but 15 more still did (T) strtoul()/strtoull()/strtol() and checked only *endptr (#725). So "-1" wrapped (--data-offset=-1 became 4294967295, --key-minimum=-1 became ULLONG_MAX), values above the field's type were truncated by the cast (--multi-key-get, --select-db, --rate-limiting=4294967297 became 1), overflow saturated, and an empty value meant 0. --max-retries used strtol() with only a "< -1" check, so 4294967295 became -1 (unlimited) and 4294967297 became 1. Unsigned options now use parse_unsigned() with the field's maximum: ULLONG_MAX for --key-minimum/--key-maximum, INT_MAX for the int fields --multi-key-get and --select-db, UINT_MAX for the rest. None of them has a sentinel other than 0, whose handling is unchanged. --max-retries uses a new signed counterpart, parse_signed(), over [-1, INT_MAX]; it accepts the same relaxed forms (leading whitespace, one sign). Messages: options where 0 is rejected (including --pipeline, -d and --reconnect-interval, as noted on #725) now go through count_option_error(), so "-1" and "5x" say "must be a positive integer", 0 says "must be greater than zero" and too-large values name the limit. Options where 0 is valid say "must be a non-negative integer" or "must be <= MAX". The errno-leak tests used --key-maximum=99999999999999999999999 to leave errno == ERANGE behind; that is now rejected, so they use --key-median=1e-310 (accepted, strtod() sets ERANGE for the subnormal result). Removing errno = 0 from parse_unsigned() and parse_backoff_factor() still fails all four of them. Release note: empty values are now rejected for --max-retries (used to mean 0, retries disabled), --data-offset, --select-db, --thread-conn-start-{min,max}-jitter-micros, --scan-incremental-max-iterations, --replica-clients and --replicas-per-shard (used to mean 0); --max-retries above 2147483647 is rejected instead of wrapping. Fixes #725 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…igned errno Review of #748: - --rate-limiting above UINT_MAX - 49 made (request_rate + 49) / 50 wrap to 0 and request_rate / 0 raise SIGFPE. The PR advertises UINT_MAX as valid, so do the rounding in 64 bits. - A --thread-conn-start-*-jitter-micros range of UINT_MAX made jitter_range + 1 wrap to 0 and rand() % 0 raise SIGFPE. Same fix. - The errno-leak test now also runs --max-retries after the stale ERANGE; removing errno = 0 from parse_signed() fails it. - C leaves ERANGE for a subnormal strtod() result implementation-defined, so the guard now checks, through ctypes, that this libc sets it for 1e-310. 1e999 (where ERANGE is required) was not used because --key-median accepting inf is itself a bug that will be fixed. - Messages for --replica-clients/--replicas-per-shard drop the "--" prefix, like the other options. - README: "-0" is now rejected on the options where 0 is valid. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The PR advertised INT_MAX for --multi-key-get, but every client preallocates keylist(multi_key_get + 1): 16 bytes of key_entry plus a 256-byte key buffer per entry. The unsigned 256 * entries buffer size wraps above 16777215 entries, and well before that the startup allocation exhausts memory (INT_MAX reached ~31 GB RSS on one client before being killed). Cap it at 1000000 (~272 MB per client) with "multi-key-get must be <= 1000000.", and say so in --help, the man page and the README release note. Also comment why parse_signed() accepts "-0" while parse_unsigned() rejects it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…et at their real bounds Review of #748: - --key-maximum=18446744073709551615 with the default --key-minimum 0 is a full 64-bit range. random_range() computed rn % (max - min + 1), which wraps to % 0 (SIGFPE with R:R), and gaussian_distribution_range() rejected every sample against max + 1 == 0, so G:G hung (it ignores SIGTERM). Treat a wrapped span as "any rn", compare against max + 1 in double, and clamp the result so a double >= 2^64 is never converted. Sequential and parallel patterns were checked and do not wrap. - --multi-key-get is capped at 16777214, the largest value for which keylist's unsigned 256 * (N + 1) buffer size does not wrap, instead of 1000000: values that used to work keep working (#212). --help and the man page note the ~272 bytes per key per client. - --data-offset is capped at (1 << 29) - 1 in the parser, so its "must be <= N" is true; the later "data-offset too long" check in main() is gone. - --rate-limiting errors say "rate-limiting must be ...". - README: the message change for --pipeline, -d and --reconnect-interval. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ts maximum - test_key_maximum_full_range_runs ran memtier against the env's server without TLS args, so it failed with "Connection reset by peer" in every TLS CI cell. It now builds the command through addTLSArgs(). The other real-run tests in the file use a closed port and need no server. - --show-config now also prints clients_start, clients_step, step_duration, scan_incremental_max_iterations, replica_clients and replicas_per_shard, and test_remaining_options_store_their_maximum checks that each option stores its full maximum (all above 65535), so a store narrowed to a smaller type or dropped is caught. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review of #748: - keylist::add_key() doubled an unsigned int buffer size, which wraps to 0 past 2 GiB and spins the growth loop forever. With the --multi-key-get cap at 16777214 that is reachable, e.g. --multi-key-get=8388607 with ~260-byte keys. The buffer size is now size_t and grows through keylist_grow_size(), which stops doubling before size_t overflows. tests/unit/keylist_growth_test.cpp covers the 2^31 step and the SIZE_MAX edge without allocating; a real run would need several GB per client. The cap comment and release note now say exactly what 16777214 guarantees: the preallocated buffer stays below 4 GiB. - Zipf samples are clamped to the range maximum, as Gaussian ones are: at --key-maximum=ULLONG_MAX a sample can be the double 2^64, whose conversion to unsigned long long is undefined. The full-range run test now also covers Z:Z. - random_range() documents that get_random() yields 62 bits, so spans above 2^62 are not uniform (unchanged behaviour). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…not grow Review of #748: - Reverting keylist::m_buffer_size to unsigned int passed every test, so a static_assert in keylist now requires it to be at least size_t wide; the helper's unit test only covers the growth arithmetic. - A failed malloc/realloc of the MGET key list (GBs with a large --multi-key-get and long keys) prints "out of memory building MGET key list" and exits 1 instead of asserting. - The --multi-key-get cap comment says what it is now: a memory sanity limit that keeps the preallocated key buffer under 4 GiB. - The JSON configuration also records scan_incremental_max_iterations, like --show-config. - Test docstrings: the Z:Z case only checks that the full range runs (its clamp is defensive), and the jitter test passes on the timeout. Blank lines fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… JSON only with scanning Review of #748: - strtoul("-0") never wrapped, so "-0" and "-00" always meant what was typed. Following #212 (keep working command lines working), parse_unsigned() now accepts one '-' when the value is zero and still rejects every real negative ("-1", "-0x", "+-0", negative overflow). This applies to every option on the helper, including #721's (which had rejected "-0" on unreleased master only). 0 keeps its meaning per option: accepted where valid, "must be greater than zero" where not; port options still reject 0. The only breaking change left is empty values. - config_print_to_json() writes scan_incremental_max_iterations only with --scan-incremental-iteration, like the staircase keys. Co-Authored-By: Claude Opus 5.5 <[email protected]>
9d17d4c to
316559b
Compare
|
Point by point on the 23:04 review. Everything is in 316559b, rebased on 38dfbaa.
🤖 Generated with Claude Code |
|
Point by point on the 23:44 review. This round only changes the PR description; there is no code push.
🤖 Generated with Claude Code |
parse_uri() read the database number of redis://host:port/N with (int) strtol() and only checked db < 0, so the cast wrapped values outside int: /4294967296 selected db 0, /4294967297 db 1, /6442450943 db 2147483647, and the saturated -99999999999999999999999 became db 0. That is the #725 class #748 fixed for --select-db. The number now goes through parse_unsigned() with an INT_MAX bound, the same rule as --select-db: leading whitespace, one '+' and "-0" are accepted; any other negative, overflow, junk and values above INT_MAX are rejected with the existing "invalid database number '...'" error. An empty path ("redis://host:port/") still selects no database, and #735's userinfo split (including the known '@'-in-path limits pinned by test_config_password_redaction.py) is unchanged. Refs #725 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Behaviour: same relaxed rule as #721. Leading whitespace and one
+are still accepted (--select-db " 2",--key-minimum=+2), asstrtoul()always accepted them (#212). Any negative value, empty input, trailing junk,ERANGEand values above the field's type are rejected with exit 2.-0and-00are accepted as 0, sincestrtoul()never wrapped them.--max-retriesalso accepts one leading-, because -1 means unlimited.Release note (also in README, "Using memtier_benchmark"):
--max-retries=(empty, for example an unset$VAR) used to mean 0 = retries disabled and is now an error. Values above 2147483647 are rejected. Before,4294967295became -1 (unlimited) and4294967297became 1.--data-offset,--select-db,--thread-conn-start-min-jitter-micros,--thread-conn-start-max-jitter-micros,--scan-incremental-max-iterations,--replica-clientsand--replicas-per-shard, where they used to mean 0. Pass0explicitly.-0keeps meaning 0 on every option that goes throughparse_unsigned(), including the options from Reject wrapped, overflowing and empty values on the 13 options in #705/#695 #721, which had rejected it on unreleased master only. Empty values are the only previously accepted, in-range input that is now rejected.-1(any negative except-0), overflow and values above the field's type are now rejected on all 15 options listed below, instead of wrapping or truncating.--multi-key-getis capped at 16777214, the largest value whose preallocated per-client key buffer (256 * (N + 1)bytes) stays below 4 GiB. It is a memory sanity limit: the sizes aresize_tnow, and the cap sits where keylist's old 32-bit size wrapped, so values that used to work keep working. Memory is left to the user: about 272 bytes per key per client, as--helpnow says. Before, INT_MAX was accepted and reached about 31 GB RSS before it was killed.--data-offsetabove 536870911 ((1 << 29) - 1) is rejected at parse time with "must be <= 536870911", instead of later with "data-offset too long".--pipeline,-dand--reconnect-intervalnow print "must be a positive integer" for-1, empty values and trailing junk; they used to print "must be greater than zero".--rate-limitingerrors now say "rate-limiting must be ..." instead of "rate must be ...".Problem
#721 left 15 options on the old
(T) strtoul()/strtoull()/strtol()pattern, which checked only*endptr:--data-offset,--key-minimum,--key-maximum,--thread-conn-start-{min,max}-jitter-micros,--multi-key-get,--select-db,--rate-limiting,--scan-incremental-max-iterations,--clients-start,--clients-step,--step-duration,--replica-clients,--replicas-per-shardand--max-retries. Examples:--data-offset=-1became 4294967295 and--key-minimum=-1became 18446744073709551615.--multi-key-get,--select-dband--rate-limitingset to 4294967297 all became 1.--key-maximum=99999999999999999999999saturated toULLONG_MAX.Root cause
These
config_parse_args()cases had no sign or leading-digit check, noerrno/ERANGEcheck and no range check before the narrowing cast.--max-retriesusedstrtol()with onlyparsed < -1and then cast toint.Fix
Unsigned options now use
parse_unsigned(s, max, &v, &too_large)from Reject wrapped, overflowing and empty values on the 13 options in #705/#695 #721, withmaxset to the field's type:ULLONG_MAXfor--key-minimumand--key-maximum;INT_MAXfor theintfield--select-db;MEMTIER_MULTI_KEY_GET_MAX) for--multi-key-get.keylist(multi_key_get + 1)preallocates 16 + 256 bytes per entry, and theunsigned256 * entriesbuffer size wraps above 16777215 entries;MEMTIER_DATA_OFFSET_MAX) for--data-offset, the limitmain()used to check after parsing;UINT_MAXfor the rest.I checked each option for sentinels: the only one is 0, and its handling is unchanged. 0 is still rejected for the key range,
--multi-key-get,--rate-limitingand the staircase options, and still accepted where--helpdocuments it (--data-offset, the jitters,--select-db,--scan-incremental-max-iterations0 = follow to the end,--replica-clients0 = inherit,--replicas-per-shard0 = all).--max-retriesuses a new signed counterpart,parse_signed(s, -1, INT_MAX, &v, &too_large). It follows the same rules asparse_unsigned(): leading whitespace, at most one sign, then a required digit. Unlikeparse_unsigned(), which accepts-only for zero, any negative value in range is valid here. It resetserrnoand rejects junk,ERANGEand values outside the range.Messages:
count_option_error(). As the follow-up on Remaining numeric options accept negative, overflowing and wrapping values (unchecked strtoul/strtoull/strtol) #725 suggested, this now includes--pipeline,-dand--reconnect-interval. So-1,5xand""give "must be a positive integer",0gives "must be greater than zero", and a value that is too large gives "must be <= MAX".count_option_error()takes an optional unit, which keeps-d's "<= 536870912 bytes (512 MiB)".--max-retrieskeeps its "integer >= -1 (-1 means unlimited)" message and adds "must be <= 2147483647".tests/test_cli_validation_size.pynow expects "positive integer" for--pipeline=-1and--data-size=-1.Errno-leak tests: they used
--key-maximum=99999999999999999999999to leaveerrno == ERANGEbehind, and that value is now rejected. They now use--key-median=1e-310, which is accepted, whilestrtod()setsERANGEfor the subnormal result. C leaves that up to the implementation, so the guard incount_flagschecks both that the value is still accepted and, throughctypes, that this host's libc setsERANGEfor it. The same test now also runs--max-retriesafter the stale errno, which coversparse_signed().SIGFPE at the maxima (also on master):
--rate-limitingaboveUINT_MAX - 49made(request_rate + 49) / 50wrap to 0, and the next division by it crashed. A--thread-conn-start-*-jitter-microsrange ofUINT_MAXmaderand() % (range + 1)becomerand() % 0. Both now do that math in 64 bits.--replica-clientsand--replicas-per-shardmessages drop the--prefix, like every other option.Full 64-bit key range (also on master):
--key-maximum=18446744073709551615with the default--key-minimum0 maderandom_range()computern % 0(SIGFPE withR:R).gaussian_distribution_range()rejected every sample againstmax + 1 == 0, soG:Ghung and ignored SIGTERM. Now a wrapped span means "anyrn", the Gaussian bound is compared indouble, and Gaussian and Zipf results are clamped to the maximum, so no double of 2^64 or more is converted.S:SandP:Pwere checked and do not wrap.get_random()yields 62 bits, soR:Rover more than 2^62 keys is not uniform, as before; the comment now says so.MGET keylist growth hang (also on master):
keylist::add_key()doubled anunsigned intbuffer size, which wraps to 0 past 2 GiB, and the growth loop never ended. It is reachable under the cap, for example with--multi-key-get=8388607and ~260-byte keys. The size is nowsize_tand grows throughkeylist_grow_size()(newkeylist_growth.h), which stops doubling beforesize_toverflows. The new unit testtests/unit/keylist_growth_test.cpp(make check) covers the 2^31 step and theSIZE_MAXedge without allocating; a mutant with anunsigned intsize hangs it. Astatic_assertinkeylistkeepsm_buffer_sizeat leastsize_twide; reverting the member tounsigned intpassed every runtime test, and a real--multi-key-get=8388607run with 250-byte keys then aborted. That run now exits 0 at ~4.5 GB RSS. A failed key-list allocation prints "out of memory building MGET key list" and exits 1 instead of asserting.Tests
New tests in
tests/test_cli_validation_count_flags.py, already in the sanitizer workflow lists:test_remaining_options_reject_wrapped_values"\n-18446744073709551000","\n-1","\v-1",-1," -5","- 5","+-5","++5","+ 5",""," ",5x,"5 ", overflow) → exit 2 + the option's messagetest_remaining_options_reject_values_above_their_type4294967297and overflow → "must be <= MAX" (UINT_MAX / INT_MAX / ULLONG_MAX / cap)test_remaining_options_messages-dunit texttest_remaining_options_accept_valid_values1, the type maximum," 5","\t5","\n5","+5"," +5", and0where validtest_max_retries_rejects_out_of_range_and_malformed-2,"\n-2",-4294967295, signed overflow both ways,"- 1","+-1","-+1","--1","++1","-","+",""," ",5x,-1x; and2147483648,4294967295,4294967297→ "<= 2147483647"test_negative_zero_is_zero-0,-00," -0","\n-0"accepted where 0 is valid and stored as 0; "must be greater than zero" where it is nottest_max_retries_accepts_valid_values-1," -1","\t-1",0,+0,-0,1," +5",2147483647test_rate_limiting_max_does_not_divide_by_zero--rate-limiting=4294967247and=4294967295against a closed port: no SIGFPEtest_jitter_max_range_does_not_divide_by_zero0..4294967295,-c 2: no SIGFPEtest_multi_key_get_captest_data_offset_captest_remaining_options_store_their_maximum--show-config(which now also prints the staircase, scan and replica fields) shows each option's full maximum, all above 65535, so a narrowed or dropped store is caughttest_key_maximum_full_range_runs-n 3against redis with--key-maximum=18446744073709551615andR:R,G:G,Z:Z,S:S,P:Pexits 0 (master: R:R SIGFPE, G:G hangs)test_remaining_options_store_the_parsed_value--show-configshows the given value:max_retries = -1(sentinel kept),= 2147483647,= 7for+7,key_maximum = 18446744073709551615,select-db = 2147483647,rate_limit = 9for" 9", ...RLTest
--env oss, port 23500:--tlslast checked at 9d17d4c: 27/27)-1messages)test_remaining_options_store_the_parsed_valuealso passes on master. It guards the accepted forms and sentinels, not the bug.Mutation check: with
errno = 0removed fromparse_unsigned()andparse_backoff_factor(), all four errno-leak tests (count_flags,ports,reconnect_backoff,retry_backoff) fail with the new--key-median=1e-310source. Witherrno = 0removed fromparse_signed(),test_unsigned_options_ignore_errno_from_earlier_optionsfails (--max-retries=5→ "must be <= 2147483647").Fixes #725
Follow-ups (not in this PR)
rand(), which only reachesRAND_MAX(2^31 - 1 on glibc). A jitter range above that never sleeps near its top. This is unchanged here; the 64-bit modulo only removes the SIGFPE.--uridatabase number (redis://host:port/N) still goes through(int) strtol. It will move to the--select-dbrule after Redact the password in --json-out-file and --show-config #735.Affected versions
Every release through 2.5.2, and master (from the issue,
git log -Sthengit tag --contains):--key-minimum,--key-maximum,--multi-key-get,--select-db: 833a8df, 1.0.0--data-offset: 295897a, 1.2.0--rate-limiting: 9ddfcff, 2.1.0--thread-conn-start-*-jitter-micros: 7ae9f65 (Connection Error Tracking & Auto-Reconnect #320),--scan-incremental-max-iterations: 0d1feab (Add SCAN incremental cursor iteration feature #347),--clients-start/-step,--step-duration: 0228bac, all 2.3.0--max-retries: 08cfc24 (feat(retry): --retry-on-error with bytes-snapshot resend + failed-keys log #381), 2.4.0--replica-clients,--replicas-per-shard: ee757e7, 2.5.0Reproduced on master 193f6a8 (the issue's exit-code table is unchanged after #721). The older versions come from history and were not run.
🤖 Generated with Claude Code
Note
Medium Risk
Wide CLI parsing changes include intentional breaking behavior for empty and out-of-range values; runtime fixes touch key generation and large MGET allocations, though coverage is extensive.
Overview
Hardens numeric CLI parsing (#725) by routing the remaining count/size options through shared
parse_unsigned()/ newparse_signed()(for--max-retries), with clearer errors, caps (--multi-key-get≤ 16777214,--data-offsetat parse time), and documented breaking behavior for empty values and overflow instead of silent wrap/truncate.-0is still accepted as zero.Fixes integer-overflow crashes and hangs that showed up at extreme settings: 64-bit math for rate-limiting and connection-start jitter (
% 0), safe full-range key sampling inobj_gen(Gaussian/Zipf/random), and MGETkeylistbuffer growth onsize_tviakeylist_grow_size()with OOM handling instead of asserts/infinite doubling.Docs and tests update README/manpage/
--help, extend--show-config/JSON for staircase and replica fields, addkeylist_growth_test, and greatly expandtest_cli_validation_count_flags.py(including live Redis runs for max key range and SIGFPE guards).Reviewed by Cursor Bugbot for commit 316559b. Bugbot is set up for automated code reviews on this repo. Configure here.