node_parameters: reject non-finite values in floating-point range check#3143
Open
bartalor wants to merge 1 commit intoros2:rollingfrom
Open
node_parameters: reject non-finite values in floating-point range check#3143bartalor wants to merge 1 commit intoros2:rollingfrom
bartalor wants to merge 1 commit intoros2:rollingfrom
Conversation
Fix ros2#2898. __check_double_range accepted +inf, -inf, and NaN for a declared floating_point_range. Two causes: 1. The boundary fast path used __are_doubles_equal, whose ULP-tolerance arithmetic degenerates on non-finite operands (e.g. it claims +inf equals any finite boundary), so +inf and -inf slipped past. 2. The bound check (value < from) || (value > to) is false on both sides for NaN, so NaN slipped past. Fix: - Guard __are_doubles_equal: if either operand is non-finite, fall back to exact ==. - Rewrite the bound check as !(value >= from && value <= to), which rejects NaN. Adds a regression test for +inf, -inf, and NaN. Signed-off-by: Bar <bartalor@gmail.com>
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.
Description
Fixes #2898.
__check_double_rangeaccepted+inf,-inf, andNaNfor parameters declared with afloating_point_range. Fix guards__are_doubles_equalagainst non-finite operands and rewrites the bound check soNaNis rejected.Is this user-facing behavior change?
Yes.
set_parameterwith+inf,-inf, orNaNon a parameter with afloating_point_rangenow returnssuccessful=false.Did you use Generative AI?
Yes — Claude Opus 4.7.
Additional Information
Adds a regression test in
test_node.cppfor the three non-finite cases. The new scope block pushes the existingTEST_Fover cpplint's 800-line limit, so a// NOLINT(readability/fn_size)is added on its closing brace — same pattern other ROS 2 packages use for this case.