PointCloudLibrary / PointCloudLibrary/pcl
Image size assumption causes memory access error in Linemod object recognition
Open
@holzers is already working on this.
Since May 22, 2014.
status: stale
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 4.7k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 6
Description
On my Ubuntu 13.04 (64 bit) system, Linemod object recognition started to crash irregularly, after applying a region of interest on my input data.
Reproduction:
- Construct a pointcloud with a size of w * h where w%16 or h%16 does not equal 0.
- Create templates using Linemod
- Try to match the templates on the input data
- This bug appears seemingly at random
Valgrind output:
==25525== Invalid write of size 2
==25525== at 0xA947A36: pcl::LINEMOD::matchTemplates(std::vector<pcl::QuantizableModality*, std::allocator<pcl::QuantizableModality*> > const&, std::vector<pcl::LINEMODDetection, std::allocator<pcl::LINEMODDetection> >&) const (linemod.cpp:288)
==25525== by 0x4E7D782: Linemod::matchTemplates(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGBA> const> const&) (linemod.cpp:166)
Solution:
In the Linemod object recognition (line 271), memory is read 16 bits at a time, causing memory errors when the input data's width or height are not a multiple of 16.
This is a hidden assumption and could either:
- be documented
- exception/error handling could be implemented, warning the user
- the best solution would be to check the input cloud size and correctly handle the last set of bits (with length < 16)
This issue actually appeared in OpenCV as well
Contributor guide
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.
Assessment
This issue has not been assessed yet.