Skip to content
This repository was archived by the owner on Oct 25, 2026. It is now read-only.

Skip the INCREX BYFLOAT overflow tests under Valgrind - #109

Closed
madolson wants to merge 2 commits into
upstream-unstable-d379883aefrom
skip-increx-overflow-valgrind
Closed

madolson wants to merge 2 commits into
upstream-unstable-d379883aefrom
skip-increx-overflow-valgrind

Conversation

@madolson

Copy link
Copy Markdown
Owner

Four INCREX BYFLOAT overflow tests in tests/unit/type/incr.tcl fail on every Valgrind daily run, and on the 9.2 backport sweep (valkey-io/valkey#4884). Valgrind emulates x87 long double at 64-bit precision, so 1e4932 + 1e4932 never overflows to infinity and the overflow branch never runs. This tags the four tests valgrind:skip, the same tag their replication.tcl twin already got in #3253. Needs backporting to 9.2.

AI generated details

Problem

Failing jobs: https://github.com/valkey-io/valkey/actions/runs/38659153622 (test-valgrind-test (integration-type), test-valgrind-no-malloc-usable-size-test (integration-type)) and https://github.com/valkey-io/valkey/actions/runs/38624991727/job/116062250934. These four are the only [err] lines in those jobs.

INCREX was added in 6ae7eb4 (#3253), first released in 9.2.0-rc1. ldbl_overflow_operand (tests/support/util.tcl:1547) chooses 1e4932 because its probe, increx byfloat 0, still succeeds under Valgrind. The overflow check is isinf(value_ld) at src/t_string.c:915. Under Valgrind it is never true. A minimal program built with gcc 13 on Ubuntu 24.04 shows this:

native:   a=1e+4932 isinf(a)=0 s=inf isinf(s)=1 s-a=inf
valgrind: a=1.18973e+4932 isinf(a)=0 s=1.18973e+4932 isinf(s)=0 s-a=-nan

The server stores the finite sum, applies the command's TTL, and replies with a nan delta. The test assertions catch exactly that. The replication.tcl test INCREX BYFLOAT arithmetic overflow does not propagate is the same operation, and #3253 already tagged it valgrind:skip with a comment explaining why. The incr.tcl copies did not get the tag.

Alternative considered

Have ldbl_overflow_operand detect Valgrind and fall back to 1e308. That relies on Valgrind arithmetic matching double on every Valgrind version. It does not: under Valgrind 3.19 on Amazon Linux 2, 1e4932 is rejected as infinity and the tests pass. The tests would also stop exercising the long double range under Valgrind, so they would test nothing Valgrind can report on. Skipping is the existing convention for this file and the replication test.

Testing

Ran in ubuntu:24.04 with Valgrind 3.22 and gcc 13, which matches CI. ./runtest --single unit/type/incr --valgrind --clients 1 on the base fails like CI does:

[err]: INCREX BYFLOAT positive arithmetic overflow returns [curr_val, 0] in tests/unit/type/incr.tcl
Expected '0' to be equal to 'nan' (context: type eval line 8 cmd {assert_equal 0 [lindex $res 1]} proc ::test)
[err]: INCREX BYFLOAT negative arithmetic overflow returns [curr_val, 0] in tests/unit/type/incr.tcl
Expected '0' to be equal to 'nan' (context: type eval line 7 cmd {assert_equal 0 [lindex $res 1]} proc ::test)
[err]: INCREX BYFLOAT overflow preserves existing TTL in tests/unit/type/incr.tcl
Expected '1e4932' to be equal to '1189731495357231765085759326628007130763444687096510237472674821233261358180483686904488595472612039915115437484839309258897667381308687426274524698341565006080871634...
[err]: INCREX BYFLOAT overflow does not apply the command's expiration in tests/unit/type/incr.tcl
Expected '-1' to be equal to '60' (context: type eval line 7 cmd {assert_equal -1 [r ttl foo]} proc ::test)

With the patch, the same run reports all four as [ignore]: ... Not supported when running under Valgrind and passes. Without --valgrind, the same binary passes all four tests.

Based on valkey-io/valkey unstable at d379883ae, so the base branch here is upstream-unstable-d379883ae.

This was generated by AI but verified, with love, by a human.

The four INCREX BYFLOAT arithmetic overflow tests in incr.tcl fail every
day in the Valgrind jobs. Valgrind computes x87 long double arithmetic
at 64-bit precision, so 1e4932 + 1e4932 is not detected as an overflow:
the sum is stored, its TTL is changed, and the reply's delta is nan.

The replication.tcl twin of these tests was already tagged valgrind:skip
when INCREX was added, as were the neighboring inf/nan INCREX tests in
incr.tcl. Tag these four the same way.

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
@madolson madolson added the promoted Change has been promoted upstream label Oct 25, 2026
@madolson madolson closed this Oct 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

promoted Change has been promoted upstream

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant