segmentation fault in loadPCDFile

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

segmentation fault in loadPCDFile

puren
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Hello, I am trying to run pcd_read.cpp tutorial. But from loadPCDFile, I get segmentation fault. I am using Mac OS Yosemite 10.10.5. I installed pcl 1.7.2 using homebrew. When I debug it here is the result
* thread #1: tid = 0x3e31e, 0x000000010005f85b libboost_filesystem-mt.dylib`boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*) + 27, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x000000010005f85b libboost_filesystem-mt.dylib`boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*) + 27
    frame #1: 0x000000010099cee3 libpcl_io.1.7.dylib`pcl::PCDReader::readHeader(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, pcl::PCLPointCloud2&, Eigen::Matrix<float, 4, 1, 0, 4, 1>&, Eigen::Quaternion<float, 0>&, int&, int&, unsigned int&, int) + 345
    frame #2: 0x00000001009a00d7 libpcl_io.1.7.dylib`pcl::PCDReader::read(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, pcl::PCLPointCloud2&, Eigen::Matrix<float, 4, 1, 0, 4, 1>&, Eigen::Quaternion<float, 0>&, int&, int) + 259
    frame #3: 0x00000001000308fd pcd_write_test`int pcl::PCDReader::read<pcl::PointXYZ>(std::string const&, pcl::PointCloud<pcl::PointXYZ>&, int) + 157
    frame #4: 0x000000010002bb23 pcd_write_test`int pcl::io::loadPCDFile<pcl::PointXYZ>(std::string const&, pcl::PointCloud<pcl::PointXYZ>&) + 51
    frame #5: 0x000000010002acc3 pcd_write_test`main + 147
    frame #6: 0x00007fff8e8b15c9 libdyld.dylib`start + 1
So it starts in readHeader. But it doesn't look like there is anything wrong with the header of the file:
$cat test_pcd.pcd 
# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z
SIZE 4 4 4
TYPE F F F
COUNT 1 1 1
WIDTH 5
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 5
DATA ascii
0.0080142021 0.694695 -0.26015043
-0.34226513 -0.44634914 0.2142067
0.17368698 -0.84253025 -0.40048075
-0.874475 0.70612717 -0.11763525
0.90851402 -0.59815884 0.74471426
I don't know what causes the problem. pcd_write.cpp worked without any problem.
Reply | Threaded
Open this post in threaded view
|

Re: segmentation fault in loadPCDFile

VictorLamoine
Administrator
Hello,

Have you tried different PCD files? Is the program crashing with all of them?

Bye
Reply | Threaded
Open this post in threaded view
|

Re: segmentation fault in loadPCDFile

puren
This post has NOT been accepted by the mailing list yet.
VictorLamoine wrote
Hello, Have you tried different PCD files? Is the program crashing with all of them? Bye
Yes I tried with the files here: https://github.com/PointCloudLibrary/data and it still gives segmentation fault.
Reply | Threaded
Open this post in threaded view
|

Re: segmentation fault in loadPCDFile

Oliwan
This post has NOT been accepted by the mailing list yet.
puren wrote
VictorLamoine wrote
Hello,

Have you tried different PCD files? Is the program crashing with all of them?

Bye
Yes I tried with the files here:
https://github.com/PointCloudLibrary/data

and it still gives segmentation fault.
Same configuration here. I tried with different PCD files (from the github link above) and from other sources without any success.

My PCL version is 1.7.2
Reply | Threaded
Open this post in threaded view
|

Re: segmentation fault in loadPCDFile

mr.charlie
In reply to this post by puren
Hello everyone,
I am having the same problem here. I have tried to run the following code which writes and successively reads a pcd file:

#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>

int main (int argc, char** argv)
{
    pcl::PointCloud<pcl::PointXYZ> cloud;

    // Fill in the cloud data
    cloud.width    = 5;
    cloud.height   = 1;
    cloud.is_dense = false;
    cloud.points.resize (cloud.width * cloud.height);

    for (size_t i = 0; i < cloud.points.size (); ++i)
    {
        cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
        cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
        cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
    }

    pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud);
    std::cerr << "Saved " << cloud.points.size () << " data points to test_pcd.pcd." << std::endl;

    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud2 (new pcl::PointCloud<pcl::PointXYZ>);

    if (pcl::io::loadPCDFile<pcl::PointXYZ> ("test_pcd.pcd", *cloud2) == -1) //* load the file
    {
        PCL_ERROR ("Couldn't read file test_pcd.pcd \n");
        return (-1);
    }

    return (0);
}


But it returns a segmentation fault on this line:
pcl::io::loadPCDFile<pcl::PointXYZ> ("test_pcd.pcd", *cloud2)

I am using Mac OS El Capitan 11.3 with pcl 1.7.2

The interesting thing is that I ran the code above with a previous version of pcl and everything worked.
I think it is a problem relative to the 1.7.2 version.

Any solution?
Reply | Threaded
Open this post in threaded view
|

Re: segmentation fault in loadPCDFile

VictorLamoine
Administrator
Hello,

Please fill an issue with as much information as possible (and a link to this topic):
- Platform
- PCL version
- Code example
- Debug output

https://github.com/PointCloudLibrary/pcl/issues

Bye