Segmentation fault when loading a .pcd file with padding fields (named "_") into point cloud tensor
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 14k
- Forks
- 2.6k
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 6
Description
Checklist
- I have searched for similar issues.
- For Python issues, I have tested with the latest development wheel.
- I have checked the release documentation and the latest documentation (for
masterbranch).
Describe the issue
I get a segmentation fault error when loading a .pcd point cloud file with padding fields (named "_") to open3d::t::geometry::PointCloud. Upon investigation, it's due to padding fields with different sizes, types and counts being mapped to the same data pointer, resulting in invalid memory access (see here and here).
I fix it by ignoring the "_" fields while iterating through the fields, which also seems to be a sensible solution implemented in the PCL library (see here).
Steps to reproduce the bug
#include <open3d/Open3D.h>
int main() {
std::string point_cloud_path{"/path/to/attached/pcd/file.pcd"};
open3d::t::geometry::PointCloud point_cloud_tensor;
open3d::t::io::ReadPointCloudFromPCD(point_cloud_path, point_cloud_tensor,
{"auto", false, false, false}); // Segmentation fault
}
Error message
==12049== Memcheck, a memory error detector
==12049== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==12049== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==12049== Command: ./build/standalone/reproduce_segfault
==12049==
==12049== Warning: set address range perms: large range [0x485b000, 0x346d8000) (noaccess)
==12049== Warning: set address range perms: large range [0x4a00000, 0x3467d000) (defined)
==12049== Invalid write of size 1
==12049== at 0x7F619C9: ??? (in /path/to/open3d-devel-linux-x86_64-cxx11-abi-cuda-0.17.0/lib/libOpen3D.so)
==12049== by 0x7F6B2C4: open3d::t::io::ReadPointCloudFromPCD(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, open3d::t::geometry::PointCloud&, open3d::io::ReadPointCloudOption const&) (in /path/to/open3d-devel-linux-x86_64-cxx11-abi-cuda-0.17.0/lib/libOpen3D.so)
==12049== by 0x10B932: main (in /path/to/point-cloud-dust-filtering/build/standalone/reproduce_segfault)
==12049== Address 0x35e14a30 is 0 bytes inside a block of size 32,768 free'd
==12049== at 0x484B27F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12049== by 0x541EB39: open3d::core::MemoryManager::Free(void*, open3d::core::Device const&) (in /path/to/open3d-devel-linux-x86_64-cxx11-abi-cuda-0.17.0/lib/libOpen3D.so)
==12049== by 0x5404A14: ??? (in /path/to/open3d-devel-linux-x86_64-cxx11-abi-cuda-0.17.0/lib/libOpen3D.so)
==12049== by 0x541F535: ??? (in /path/to/open3d-devel-linux-x86_64-cxx11-abi-cuda-0.17.0/lib/libOpen3D.so)
==12049== by 0x5431203: open3d::core::Tensor::operator=(open3d::core::Tensor const&) & (in /path/to/open3d-devel-linux-x86_64-cxx11-abi-cuda-0.17.0/lib/libOpen3D.so)
==12049== by 0x7D50E47: open3d::t::geometry::PointCloud::SetPointAttr(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, open3d::core::Tensor const&) (in /path/to/open3d-devel-linux-x86_64-cxx11-abi-cuda-0.17.0/lib/libOpen3D.so)
==12049== by 0x7F69C9C: open3d::t::io::ReadPointCloudFromPCD(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, open3d::t::geometry::PointCloud&, open3d::io::ReadPointCloudOption const&) (in /path/to/open3d-devel-linux-x86_64-cxx11-abi-cuda-0.17.0/lib/libOpen3D.so)
==12049== by 0x10B932: main (in /path/to/build/standalone/reproduce_segfault)
==12049== Block was alloc'd at
==12049== at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12049== by 0x5426612: open3d::core::MemoryManagerCPU::Malloc(unsigned long, open3d::core::Device const&) (in /path/to/open3d-devel-linux-x86_64-cxx11-abi-cuda-0.17.0/lib/libOpen3D.so)
==12049== by 0x541EA85: open3d::core::MemoryManager::Malloc(unsigned long, open3d::core::Device const&) (in /path/to/open3d-devel-linux-x86_64-cxx11-abi-cuda-0.17.0/lib/libOpen3D.so)
==12049== by 0x5404B2F: ??? (in /path/to/open3d-devel-linux-x86_64-cxx11-abi-cuda-0.17.0/lib/libOpen3D.so)
==12049== by 0x542F348: open3d::core::Tensor::Empty(open3d::core::SizeVector const&, open3d::core::Dtype, open3d::core::Device const&) (in /path/to/open3d-devel-linux-x86_64-cxx11-abi-cuda-0.17.0/lib/libOpen3D.so)
==12049== by 0x7F69C8A: open3d::t::io::ReadPointCloudFromPCD(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, open3d::t::geometry::PointCloud&, open3d::io::ReadPointCloudOption const&) (in /path/to/open3d-devel-linux-x86_64-cxx11-abi-cuda-0.17.0/lib/libOpen3D.so)
==12049== by 0x10B932: main (in /path/to/build/standalone/reproduce_segfault)
==12049==
==12049==
==12049== HEAP SUMMARY:
==12049== in use at exit: 1,571 bytes in 5 blocks
==12049== total heap usage: 47,430 allocs, 47,425 frees, 4,436,608 bytes allocated
==12049==
==12049== LEAK SUMMARY:
==12049== definitely lost: 0 bytes in 0 blocks
==12049== indirectly lost: 0 bytes in 0 blocks
==12049== possibly lost: 0 bytes in 0 blocks
==12049== still reachable: 1,571 bytes in 5 blocks
==12049== suppressed: 0 bytes in 0 blocks
==12049== Rerun with --leak-check=full to see details of leaked memory
==12049==
==12049== For lists of detected and suppressed errors, rerun with: -s
==12049== ERROR SUMMARY: 131072 errors from 1 contexts (suppressed: 0 from 0)
Expected behavior
The point cloud file should load successfully into the point cloud tensor. As described above, it should be fixed by ignoring the padding fields (named "_"), similar to the PCL library implementation.
Open3D, Python and System information
- Operating system: Ubuntu 22.04
- Python version: Python 3.10 (irrelevant)
- Open3D version: 0.17.0
- System architecture: x86
- Is this a remote workstation?: no
- How did you install Open3D?: [pre-built C++ library](https://github.com/isl-org/Open3D/releases/download/v0.17.0/open3d-devel-linux-x86_64-cxx11-abi-cuda-0.17.0.tar.xz)
- Compiler version (if built from source): gcc 7.5 / clang 7.0
Additional information
In a Linux terminal window, you can see the padding fields and their size type and count by running head -n 11 {path_to_the_pcd_file}.
Let me know if you want me to submit a PR.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in cpp/open3d/t/io/file_format/FilePCD.cpp at the linked field-handling locations, then inspect the sample .pcd header to understand its padding fields. Reproduce the load with the provided C++ example and verify that padding fields named "_" no longer cause invalid memory access and the point cloud loads successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100