node_parameters: reject non-finite values in floating-point range check#3143
node_parameters: reject non-finite values in floating-point range check#3143bartalor wants to merge 1 commit into
Conversation
| {node->remove_pre_set_parameters_callback(handler.get());}); // always reset | ||
| } | ||
| } | ||
| } // NOLINT(readability/fn_size) |
There was a problem hiding this comment.
test function has been growing for a while.
i understand that this is not for this PR's job to refactor, but we might ask for the new block to be split into its own test fixture instead. that would also be cleaner because the test name (set_parameter_undeclared_parameters_not_allowed) doesn't really describe the new assertion...
There was a problem hiding this comment.
Hey, thanks for the feedback — agreed the test function has grown too big.
That said, my new case is testing node->set_parameter under the allow_undeclared_parameters(false) constraint, so it does fit this fixture. I'm a bit worried that pulling it out into its own TEST_F would raise the question of why it doesn't belong with set_parameter_undeclared_parameters_not_allowed in the first place.
Happy to split it if you still prefer, but wanted to flag the category concern first.
|
Pulls: #3143 |
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>
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.