Inverted cloud width and height causing seg fault with pcl_conversions
Issue #26
resolved
Hi,
it seems this commit https://bitbucket.org/DataspeedInc/velodyne_simulator/commits/effeed2084ca904542ec9f9d1ac3dd12b91c22c6 introduced a bug when we convert the point cloud using pcl::fromROSMsg() function. Internally, this code will eventually be called:
// If not, memcpy each group of contiguous fields separately for (index_t row = 0; row < msg.height; ++row) { const std::uint8_t* row_data = &msg.data[row * msg.row_step]; for (index_t col = 0; col < msg.width; ++col) { const std::uint8_t* msg_data = row_data + col * msg.point_step; for (const detail::FieldMapping& mapping : field_map) { memcpy (cloud_data + mapping.struct_offset, msg_data + mapping.serialized_offset, mapping.size); } cloud_data += sizeof (PointT); } }
The code crashes in the memcpy
because the row_step
is not set correctly in the message or width
/ height
are inverted. The bug is coming from here:
msg.width = 1; msg.height = msg.data.size() / POINT_STEP; msg.row_step = msg.data.size();
Inverting the width and height avoids the pcl_conversion seg fault as explained in this issue: https://github.com/introlab/rtabmap_ros/issues/560
Note that the organized version is fine (when launching the plugin with organized_cloud=true
).
Regards,
Mathieu
Comments (3)
-
-
reporter Yes!
-
- changed status to resolved
- Log in to comment
Does PR #12 fix this issue?