Repository navigation
bindings/ruby: fix tuple float comparison on Ruby 3.3 and later - #14507
Merged
Merged
Conversation
FDB::Tuple._compare_floats packed its arguments with the format strings ">g" and ">G". ">" is only a modifier for the integer directives; in front of "g"/"G" it is an unknown directive. Older Rubies ignored it (with a warning under -w), but since Ruby 3.3 Array#pack raises ArgumentError for unknown directives. As a result FDB::Tuple.compare raised for any pair of tuples that reached a float or double comparison, and so did FDB::Tuple::SingleFloat#<=>. "g" and "G" are already big-endian, so drop the ">". The packed bytes are the same as before on Rubies that ignored it. Add a TUPLE_SORT of tuples containing floats and doubles to the scripted binding test, which until now did not sort tuples at all. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: Dezhen Lu <[email protected]>
Contributor
Result of foundationdb-pr-macos-m1 on macOS
|
Contributor
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-clang-arm on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-clang on Linux RHEL 9
|
Contributor
Result of foundationdb-pr on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-macos on macOS
|
Contributor
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
ploxiln
approved these changes
Nov 11, 2026
ploxiln
pushed a commit
that referenced
this pull request
Nov 13, 2026
FDB::Tuple._compare_floats packed its arguments with the format strings ">g" and ">G". ">" is only a modifier for the integer directives; in front of "g"/"G" it is an unknown directive. Older Rubies ignored it (with a warning under -w), but since Ruby 3.3 Array#pack raises ArgumentError for unknown directives. As a result FDB::Tuple.compare raised for any pair of tuples that reached a float or double comparison, and so did FDB::Tuple::SingleFloat#<=>. "g" and "G" are already big-endian, so drop the ">". The packed bytes are the same as before on Rubies that ignored it. Add a TUPLE_SORT of tuples containing floats and doubles to the scripted binding test, which until now did not sort tuples at all. Signed-off-by: Dezhen Lu <[email protected]> Co-authored-by: Claude Fable 5.2 <[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
Fixes #14505.
On Ruby 3.3 and later,
FDB::Tuple.compareraisesArgumentError: unknown pack directive '>' in '>G'as soon as it compares two doubles, andFDB::Tuple::SingleFloat#<=>raises the same for'>g'.FDB::Tuple._compare_floatspacks its arguments with">G"/">g".>is not valid in front ofg/G; older Rubies ignored it with a warning, and Ruby 3.3 turned unknownpackdirectives into an error.Found by reading
bindings/ruby/lib/fdbtuple.rbwith an AI assistant (Claude Code, claude-fable-5-2) and reproduced with the Ruby binding tester on Ruby 3.4.7: theapitest stops inTUPLE_SORT.Solution
Use
"G"/"g". Both are big-endian already, so the bytes are the same as before on Rubies that ignored the>.The scripted binding test gets a
TUPLE_SORTof tuples with doubles,SingleFloats and nested0.0/-0.0. It had noTUPLE_SORTso far, which is whyscriptedpasses for Ruby on main even on Ruby 3.4.Testing
Run against a single-process cluster from the 8.0.0 release binaries, binding sources from this branch, x86_64 Linux:
./bindingtester.py ruby --test-name scriptedon Ruby 3.4.7: fails on main once the newTUPLE_SORTblock is added (ArgumentError), passes with the fix../bindingtester.py ruby --test-name api --num-ops 1000 --seed 12345on Ruby 3.4.7: fails on main, passes with the fix../bindingtester.py python --test-name scriptedand--test-name api --num-ops 1000 --seed 12345: pass with the new block.FDB::Tuple.compareandSingleFloat#<=>(in the issue) gives the expected results on Ruby 3.2.9, 3.3.10 and 3.4.7 with the fix; on main it raises on 3.3.10 and 3.4.7 and warns on 3.2.9.black22.8.0 andflake85.0.4 onbindings/bindingtester/tests/scripted.py: clean.Not run: the CMake build,
ctest, Joshua, and the Java, Go, Flow and Swift binding testers. The new scripted block also runs for those testers; if that is a concern, the block can be dropped, since the existingapitest already covers the failure.AI disclosure: Claude Code, model claude-fable-5-2; AI was used to find the bug, write the reproducer, the fix and the test, run the tests listed above, and write the first draft of this description; AI-generated code:
bindings/ruby/lib/fdbtuple.rblines 311-312 and theTUPLE_SORTblock inbindings/bindingtester/tests/scripted.py.🤖 Generated with Claude Code