node_parameters: reject non-finite values in floating-point range check (backport #3143) - #3161
Conversation
…ck (#3143) Fix #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> (cherry picked from commit fa8478f)
|
Pulls: #3161 |
|
Pulls: #3161 |
|
This PR breaks API in Please revert this. Comparing infinite values is a perfectly valid operation. E.g. in Python: In [1]: import numpy as np
In [2]: np.inf == np.inf
Out[2]: True
In [3]: np.inf < np.inf
Out[3]: False
In [4]: np.inf <= np.inf
Out[4]: True |
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.This is an automatic backport of pull request #3143 done by [Mergify](https://mergify.com).