Skip to content

Segmentation Fault in Feature::SelectByIndex #7211

@svark

Description

@svark

Checklist

Describe the issue

The method Feature::SelectByIndex seg faults for any input if the argument invert is set to true.

output is incorrectly assumed to be the same as indices.size()
output->Resize(data_.rows(), indices.size());

and this leads to buffer overruns during copy.

The correct size should be count of true values in the mask (note : indices may not be unique). Alternatively we may use push_back without setting any prior size.

Steps to reproduce the bug

core::Device device = GetParam();

    open3d::geometry::PointCloud pcd_legacy;
    data::BunnyMesh bunny;
    open3d::io::ReadPointCloud(bunny.GetPath(), pcd_legacy);

    pcd_legacy.EstimateNormals();
    // Convert to float64 to avoid precision loss.
    const auto pcd = t::geometry::PointCloud::FromLegacy(pcd_legacy,
                                                         core::Float64, device);

    const auto fpfh = pipelines::registration::ComputeFPFHFeature(
            pcd_legacy, geometry::KDTreeSearchParamHybrid(0.01, 100));
    const auto fpfh_t =
            t::pipelines::registration::ComputeFPFHFeature(pcd, 100, 0.01);

    const auto selected_fpfh =
            fpfh->SelectByIndex({53, 194, 839, 2543, 6391, 29483}, true);

Error message

Seg fault

Expected behavior

No response

Open3D, Python and System information

- Operating system: Ubuntu 20.04 / macOS 10.15 / Windows 10 64-bit
- Python version: Python 3.8 / output from `import sys; print(sys.version)`
- Open3D version: output from python: `print(open3d.__version__)`
- System architecture: x86 / arm64 / apple-silicon / jetson / rpi
- Is this a remote workstation?: yes or no
- How did you install Open3D?: pip / conda / build from source
- Compiler version (if built from source): gcc 7.5 / clang 7.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugNot a build issue, this is likely a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions