PointCloudLibrary / pcl

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

Invalid read of size 4 asinLookUp (range_image.hpp:55) pcl::RangeImage::getImagePoint Address 0xfffffffe21a9ff80 is not stack'd, malloc'd or (recently) free'd #3479

Closed arunumd closed 4 years ago

arunumd commented 4 years ago

My Environment

Context

I am trying to convert a point cloud into a range image. I followed the tutorials on this page. But I get a segmentation fault when I do exactly the same thing said in the tutorial.

Expected Behavior

The code from the tutorial above should output a range image.

Current Behavior

The code fails with a segmentation fault and does not create a range image.

Code to Reproduce

Following the code in this tutorial produces the bug found below in the error.txt file

I ran the following commands to run this code :

cmake .. && make
./range_image_visualization 1.pcd

The error generated through valgrind tool is attached below : error.txt

mvieth commented 4 years ago

@arunumd Please provide your file 1.pcd. I tried the program with the auto-generated cloud (i.e. without command line parameter), and with a pcd file I have, but the segmentation fault did not occur. The problem might have been caused by your pcd file.

mvieth commented 4 years ago

@arunumd To avoid a misunderstanding: this doesn't mean that this shouldn't be investigated. It is possible that there is a bug in pcl, or it lacks safety measures. Or did you already find out what the problem is?

arunumd commented 4 years ago

Hi @mvieth, thanks for getting back. Since this file contained proprietary information, I had to manually crop-out the sensitive parts in the file and upload it. Right now I am also getting another new problem (couple of warning messages from pcl) apart from the original segmentation fault.

arun@arun-VirtualBox:~/Documents/playground/build$ ./range_image_visualization ../file.pcd 
Failed to find match for field 'x'.
Failed to find match for field 'y'.
Failed to find match for field 'z'.
Segmentation fault (core dumped)

GitHub does not allow us to post a file with .pcd extension on the issues page. Hence, I have renamed my file.pcd to file.txt. Please rename the extension back to .pcd. This is the file below : file.txt

mvieth commented 4 years ago

First insights: I put a debug here which gave: [pcl::RangeImage::getImagePoint] range=0, transformedPoint=(0,0,0), point=(0,0,0). And a debug here which gave: [pcl::RangeImage::asinLookUp] called asinLookUp(value=-nan).

So I guess the question is why is there a point (0,0,0) if it is not in the initial cloud and where should the test go that prevents this segfault. I will get back to you when I know more.

mvieth commented 4 years ago

@arunumd Could you please put this code at line 114 of the tutorial (between reading in the cloud and creating the range image) and post the result here:

std::cout << "point_cloud=" << point_cloud << std::endl;
for(size_t i=0; i<10; i++) {
  std::cout << point_cloud[i] << std::endl;
}

Please use the original file (containing the sensitive parts). That one did not give you messages like Failed to find match for field, did it? Thanks in advance.

mvieth commented 4 years ago

@arunumd Where did you get the PCD file from/how did you generate it, if you don't mind me asking? I noticed that it uses 64bit floats instead of the 32bit floats PCL usually uses (as far as I know).

One problem seems to be that PCL does not recognize the fields x, y, z when reading the file because they don't have the expected type (double instead of float). The cloud then only consists of (0,0,0) points, which causes the segfault.

arunumd commented 4 years ago

@arunumd Where did you get the PCD file from/how did you generate it, if you don't mind me asking? I noticed that it uses 64bit floats instead of the 32bit floats PCL usually uses (as far as I know).

One problem seems to be that PCL does not recognize the fields x, y, z when reading the file because they don't have the expected type (double instead of float). The cloud then only consists of (0,0,0) points, which causes the segfault.

Dear @mvieth. Thanks for trying to investigate this. I was not sure what was causing the cloud with (0, 0, 0). I used Agisoft Metashape software for editing my raw point cloud. I also realized that the software increased the float precision further when I processed the point cloud and saved it as a new .pcd file. I think your suggestion was right. I tried to set the precision of the .pcd file as the same precision it was originally. The problem got solved.

kunaltyagi commented 4 years ago

Thanks for getting back on this @arunumd