Repository navigation
freeing Time members in destructor, adding copy constructor / assignment operator - #362
Conversation
|
there's a |
| rclcpp::exceptions::throw_from_rcl_error( | ||
| ret, "could not get current time stamp"); | ||
| } | ||
|
|
| rclcpp::Time system_time(1, 0, RCL_SYSTEM_TIME); | ||
| rclcpp::Time steady_time(2, 0, RCL_STEADY_TIME); | ||
| rclcpp::Time system_time(0, 0, RCL_SYSTEM_TIME); | ||
| rclcpp::Time steady_time(0, 0, RCL_STEADY_TIME); |
There was a problem hiding this comment.
What's the purpose of this change?
There was a problem hiding this comment.
to demonstrate that even though the timestamps are equal, the operator== fails because of the different time sources.
There was a problem hiding this comment.
Maybe this should just be added as an additional test? Sounds like a good distinction.
|
I think there is something missing here. The patch tries to fix a memory ownership problem which is likely not specific to Windows Debug. The underlying It is certainly good to add the copy constructor / assignment operator to make the two While most of the time sources only set the data pointer to something "fixed" So as a conclusion the destructor of |
dirk-thomas
left a comment
There was a problem hiding this comment.
Can you also please add tests for the problematic cases in order to ensure they all pass now as well as in the future.
|
|
||
| void | ||
| Time::operator=(const Time & rhs) | ||
| { |
There was a problem hiding this comment.
Can you try that with a RCL_ROS_TIME? Since it internally allocates data within the rcl_time_source_t I would expect that this can't be just copied here.
|
|
||
| for (auto time_source : {RCL_ROS_TIME, RCL_SYSTEM_TIME, RCL_STEADY_TIME}) { | ||
| rclcpp::Time time = rclcpp::Time(0, 0, time_source); | ||
| rclcpp::Time copy_constructor_time = time; |
There was a problem hiding this comment.
This should be rclcpp::Time copy_constructor_time(time) if you want to call the copy constructor.
There was a problem hiding this comment.
this line will also call the copy constructor.
There was a problem hiding this comment.
True, maybe still update the line to make the intention clear?
dirk-thomas
left a comment
There was a problem hiding this comment.
lgtm
Did you try running test_time in valgrind?
|
MacOS memory sanitizer doesn't complain, so I'll take this as a valid outcome. |
* fix rosbag2_tests resources and play_end_to_end test Signed-off-by: Mabel Zhang <[email protected]> * remove comment Signed-off-by: Mabel Zhang <[email protected]> * add colon after End in info Signed-off-by: Mabel Zhang <[email protected]> * fix test for buildfarm linux failure Signed-off-by: Mabel Zhang <[email protected]> * fix timestamp for mac test failure Signed-off-by: Mabel Zhang <[email protected]>
Connects to #357
add a copy constructor to the rclcpp::Time class which is necessary to fix the windows debug tests.
I tested it locally on my windows machine.
CI:
