Inverted cloud width and height causing seg fault with pcl_conversions

Issue #26 resolved
Mathieu Labbé created an issue


it seems this commit 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 = &[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 = / POINT_STEP;
    msg.row_step =;

Inverting the width and height avoids the pcl_conversion seg fault as explained in this issue:

Note that the organized version is fine (when launching the plugin with organized_cloud=true).


Comments (3)

  1. Log in to comment