Hi, I'm researching on testing ROS program and improve the robustness of programs facing possible malformed inputs. There are several improvements can be made for a more robust running.
There are two possible bugs with malformed user input:
First, there is no check for the pub_period, if a negative or zero value is set to the period, there will be a crash throwing the error 'std::invalid_argument' when set the publisher:
terminate called after throwing an instance of 'std::invalid_argument'
what(): timer period cannot be negative
Second, there is a possibility that the timestamp of the pose message can be negative because of malfunction or intentional design. And there will be an exception 'std::runtime_error' when set the value to a TimePoint:
[INFO] [1668342157.570762430] [loc2d_ros]: New laser configured (id=0 frame_id=base_scan)
terminate called after throwing an instance of 'std::runtime_error'
what(): cannot store a negative time point in rclcpp::Time
Therefore, I add a senmantic check for pub_period as the same as the other params, and catch the exception in the imu_callback. Hope you can accept the PRs.
Basic Info
Description of the bugs
Hi, I'm researching on testing ROS program and improve the robustness of programs facing possible malformed inputs. There are several improvements can be made for a more robust running.
There are two possible bugs with malformed user input:
First, there is no check for the
pub_period
, if a negative or zero value is set to the period, there will be a crash throwing the error'std::invalid_argument'
when set the publisher:crash info:
Second, there is a possibility that the timestamp of the pose message can be negative because of malfunction or intentional design. And there will be an exception
'std::runtime_error'
when set the value to aTimePoint
:crash info:
Therefore, I add a senmantic check for
pub_period
as the same as the other params, and catch the exception in theimu_callback
. Hope you can accept the PRs.