Closed jncfa closed 1 year ago
@jncfa thanks for the issue. Surprising though since both me and @ptruka have tested it. I don't have access to the device, but I will go to office this week and test again. In the mean time could you please tell us your distro of Ubuntu and ROS, and also the firmware of the device you are using?
Info from the LiDAR:
"product":"OMD30M-R2000-B23-V1V1D-HD-1L",
"revision_fw":"1.60",
"revision_hw":"1.62",
We had this issue on ROS2 Galactic using Ubuntu 20.04.6 LTS. In the mean time I can give you a few more pointers for this issue*:
Thanks a lot for the pointers @jncfa! Tomorrow I will get hold of the device and test it.
Hi @ipa-hsd, do you have any updates about this issue?
@jncfa I have the exact same configuration as you:
I ran the driver for the whole day yesterday without problems. Without recreating the error, it is difficult to debug it. I will spend some time today to think what might be causing this. In the mean time, if you have more ideas, please let me know.
I doubt anything is going wrong in run_read
. The packet is read in this function
https://github.com/PepperlFuchs/pf_lidar_ros_driver/blob/df8047e2b4f075032a42fa07074d09e13a9e089c/src/pf_driver/src/ros/pf_data_publisher.cpp#L54
and as you see it is never explicitly free'd.
Maybe something is going wrong while parsing the packets? here is where it happens https://github.com/PepperlFuchs/pf_lidar_ros_driver/blob/df8047e2b4f075032a42fa07074d09e13a9e089c/src/pf_driver/include/pf_driver/pf/pf_parser.h#L14-L46
I'll try to create a minimal Dockerfile that can emulate our system for this case Testing with gcc-10 also creates the segfault in the same place
The problem doesn't seem to be in run_reader, but rather is probably in the packet parsing or in the queue handling If you remove the reader->read() and replace it with just a packet.reset() it will also segfault.
I think I've found out the problem, because PFPacket doesn't have a virtual destructor you get undefined behaviour when destroying any derived packet The packets are created in the PFParser::parse() depending on the packet type, but the destructor that seems to be always called is PFPacket::~PFPacket()
Could you please implement the destructor for the packet type you are using and test it if it solves the problem? If it does, I can implement for the remaining of the packets. Thanks for looking into this!
You can just declare a virtual destructor PFPacket like this: virtual ~PFPacket() = default;
because all derived classes with inherit the virtualness of the destructor regardless I don't think you need to explicitly define the destructor, you can let the compiler write it for you
This at least fixed the segfault for me
That's great to hear! Could you please make a PR against https://github.com/PepperlFuchs/pf_lidar_ros_driver/tree/porting-ros2 branch?
@jncfa could you please confirm if this is what you meant? https://github.com/PepperlFuchs/pf_lidar_ros_driver/pull/83/commits/f96eba624beeba9120644e20b234e7266e26f8ae
@jncfa could you please confirm if this is what you meant? f96eba6
Yes, that should be it!
I also ended up doing that for all other base classes that are used on the driver (Reader, Writer, etc..), among some other things, I'll try to see if I can get these changes also pushed here
I'll try to see if I can get these changes also pushed here
That would be great! Thanks for your contribution
@jncfa I will close this issue now since you confirmed that your fix solves the issue.
I also ended up doing that for all other base classes that are used on the driver (Reader, Writer, etc..),
Feel free to make a PR against porting-ros2
branch whenever you can
Using the latest code from the porting-ros2 branch, the driver crashes shortly after connecting to the R2000 lidar, regardless of what parameters are used:
The stack trace indicates the segfault is here: https://github.com/PepperlFuchs/pf_lidar_ros_driver/blob/056e9c183fd45c20d9d8039e33509dd1cc50a4ae/src/pf_driver/src/pf/pipeline.cpp#L113