-
Notifications
You must be signed in to change notification settings - Fork 522
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
In message_memory_strategy.hpp The following custom deleter is used for a std::shared_ptr:
rclcpp/rclcpp/include/rclcpp/message_memory_strategy.hpp
Lines 94 to 101 in 6b34bcc
| auto serialized_msg = std::shared_ptr<rcl_serialized_message_t>(msg, | |
| [](rmw_serialized_message_t * msg) { | |
| auto ret = rmw_serialized_message_fini(msg); | |
| delete msg; | |
| if (ret != RCL_RET_OK) { | |
| rclcpp::exceptions::throw_from_rcl_error(ret, "leaking memory"); | |
| } | |
| }); |
According to https://en.cppreference.com/w/cpp/memory/shared_ptr/shared_ptr a deleter is forbidden to throw exceptions.
4-5) Uses the specified deleter d as the deleter. The expression d(ptr) must be well formed, have well-defined behavior and not throw any exceptions. The construction of d and of the stored deleter from d must not throw exceptions.
I understand that is is rather unlikely for this deleter to throw but IMHO it would be better to avoid throwing at all within the deleter.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working