I'm currently developping an application for the google tango tablet, so I have build pcl for ARM using the superbuild script (from https://github.com/Sabotaz/pcl-superbuild-with-release/releases).
I experience a strange crash : one of the pcl function, pcl::ProjectInliers, makes a «Fatal signal 7 (SIGBUS)» error.
I didn't completly understand this error, the doc says that «it could happend when dereferencing a misaligned pointer, such as referring to a four-word integer at an address not divisible by four.», so I don't understand, looking to my code, how it can happens.
Beside, all my variables seems to be well aligned (I checked that using https://stackoverflow.com/a/1898156/5533171).
Backtraces seems to involves Eigen data structure misalignment, so I think the issue is not in my code, but on the 3rd party libraries.
Here is the relevant part of my code (based on http://www.pointclouds.org/documentation/tutorials/planar_segmentation.php):
template<typename T> void SegmentationEngine<T>::ransac_loop(typename pcl::PointCloud<T>::Ptr cloud_blob, std::vector<Datatype::RansacPlane<T>>& planes) {
LOGD("size : %d", cloud_blob->points.size ());
typename pcl::PointCloud<T>::Ptr cloud (new pcl::PointCloud<T>);
copyPointCloud(*cloud_blob, *cloud);
int i = 0;
while (i < FILTER_SEGMENTATION_MAX_PLANES_NUMBER) {
typename pcl::PointCloud<T>::Ptr points (new pcl::PointCloud<T>);
pcl::PointIndices::Ptr inliers (new pcl::PointIndices ());
pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients ());
LOGD("remaining : %d", cloud->points.size ());
LOGD("Filters::sac_segmentation");
if (!Filters::sac_segmentation<T>(cloud,inliers, coefficients)) break; // plus de plans
LOGD("found plane with %d pts", inliers->indices.size());
// it crash here :
Filters::project_inliers<T>(cloud, inliers, coefficients, points, false); // don't copy all (extract)
planes.push_back( Datatype::RansacPlane<T>{ coefficients, points } );
typename pcl::PointCloud<T>::Ptr remaining (new pcl::PointCloud<T>);
Filters::extract_indices<T>(cloud, inliers, remaining, true); // remaining
cloud.swap(remaining);
i++;
}
LOGD("n planes : %d", planes.size());
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<typename T> bool sac_segmentation(typename pcl::PointCloud<T>::Ptr input_cloud, pcl::PointIndices::Ptr inliers, pcl::ModelCoefficients::Ptr coefficients) {
// Create the segmentation object
pcl::SACSegmentation<T> seg;
// Optional
seg.setOptimizeCoefficients (FILTER_SAC_SEGMENTATION_OPTIMIZE_COEFFICIENTS);
// Mandatory
seg.setModelType (FILTER_SAC_SEGMENTATION_MODEL_TYPE);
seg.setMethodType (FILTER_SAC_SEGMENTATION_METHOD_TYPE);
seg.setDistanceThreshold (FILTER_SAC_SEGMENTATION_DISTANCE_THRESOLD);
seg.setMaxIterations (FILTER_SAC_SEGMENTATION_MAX_ITERATIONS);
seg.setInputCloud (input_cloud);
seg.segment (*inliers, *coefficients);
if (inliers->indices.size () == 0)
{
return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<typename T> void project_inliers(typename pcl::PointCloud<T>::Ptr input_cloud, pcl::PointIndices::Ptr inliers, pcl::ModelCoefficients::Ptr coefficients, typename pcl::PointCloud<T>::Ptr output_cloud, bool copyall) {
// Project the model inliers
typename pcl::ProjectInliers<T> proj;
proj.setModelType (FILTER_PROJECT_INLIERS_MODEL_TYPE);
if (inliers != NULL)
proj.setIndices (inliers);
proj.setInputCloud (input_cloud);
proj.setModelCoefficients (coefficients);
proj.setCopyAllData (copyall);
// it crash here :
proj.filter (*output_cloud);
}
Here are the corresponding log :
D/fr.limsi.registration: size : 36
D/fr.limsi.registration: remaining : 36
D/fr.limsi.registration: Filters::sac_segmentation
D/fr.limsi.registration: found plane with 36 pts
A/libc: Fatal signal 7 (SIGBUS) at 0x4be4fa38 (code=1), thread 1052 (si.registration)
here is the backtrace :
backtrace:
#00 pc 0055d55e /data/app-lib/fr.limsi.registration-1/libintegration.so
(std::vector<pcl::PointXYZRGBNormal, Eigen::aligned_allocator_indirection<pcl::PointXYZRGBNormal>
>::_M_fill_insert(__gnu_cxx::__normal_iterator<pcl::PointXYZRGBNormal*,
std::vector<pcl::PointXYZRGBNormal, Eigen::aligned_allocator_indirection<pcl::PointXYZRGBNormal> >
>, unsigned int, pcl::PointXYZRGBNormal const&)+621)
#01 pc 0064d995 /data/app-lib/fr.limsi.registration-1/libintegration.so
(std::vector<pcl::PointXYZRGBNormal, Eigen::aligned_allocator<pcl::PointXYZRGBNormal>
>::resize(unsigned int)+116)
#02 pc 008cc23b /data/app-lib/fr.limsi.registration-1/libintegration.so
(pcl::SampleConsensusModelPlane<pcl::PointXYZRGBNormal>::projectPoints(std::vector<int,
std::allocator<int> > const&, Eigen::Matrix<float, -1, 1, 0, -1, 1> const&,
pcl::PointCloud<pcl::PointXYZRGBNormal>&, bool)+514)
#03 pc 0066b457 /data/app-lib/fr.limsi.registration-1/libintegration.so
(pcl::ProjectInliers<pcl::PointXYZRGBNormal>::applyFilter(pcl::PointCloud<pcl::PointXYZRGBNormal>&)+
82)
If someone have an idea of what could happend, let me know :)
Thank you,
Sablier