PointCloudLibrary / pcl

Point Cloud Library (PCL)
https://pointclouds.org/
Other
9.89k stars 4.61k forks source link

Image size assumption causes memory access error in Linemod object recognition #691

Open alexander-hagg opened 10 years ago

alexander-hagg commented 10 years ago

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:

        ==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:

This issue actually appeared in OpenCV as well

jspricke commented 10 years ago

Hi @holzers can you have a look into this? Thanks!

alexander-hagg commented 10 years ago

For my current research project I'd like to solve this issue, just to get everything right and not be dependent on my region of interest being a multiple of 16. I will try to figure out a solution in my fork using the last proposed solution (correct handling of the last set of bits).

taketwo commented 10 years ago

:+1:

stale[bot] commented 4 years ago

Marking this as stale due to 30 days of inactivity. It will be closed in 7 days if no further activity occurs.