3、Tried to other flags like -O -O1 -O2. They didn't work either.
4、Tried to use GDB debug
error occurred in Eigen lib
/** \internal Frees memory allocated with handmade_aligned_malloc */
EIGEN_DEVICE_FUNC inline void handmade_aligned_free(void *ptr)
{
if (ptr) {
EIGEN_USING_STD(free)
free(*(reinterpret_cast<void**>(ptr) - 1)); // error occurred at this line
}
}
It finished the main rigid function but copy Result struct.
/// Our base matrix class.
typedef Eigen::MatrixXd Matrix;
/// Typedef for our specific type of vector.
typedef Eigen::VectorXd Vector;
/// Typedef for an index vector, used to index other matrices.
typedef Eigen::Matrix<Matrix::Index, Eigen::Dynamic, 1> IndexVector;
/// Typedef for our specific type of array.
typedef Eigen::ArrayXd Array;
/// The result of a generic transform run.
struct Result {
/// The final moved points.
Matrix points;
/// The final sigma2 value.
double sigma2;
/// The correspondence vector.
IndexVector correspondence;
/// The runtime.
std::chrono::microseconds runtime;
/// The number of iterations.
size_t iterations;
/// De-normalize this result.
///
/// Generally, this scales the points back, and sometimes adjust transforms
/// or shifts or the like.
virtual void denormalize(const Normalization& normalization);
};
struct RigidResult : public Result {
/// The rotation component of the transformation.
Matrix rotation;
/// The translation component of the transformation.
Vector translation;
/// The scaling component of the transformation.
double scale;
/// Returns a single matrix that contains all the transformation
/// information.
Matrix matrix() const;
void denormalize(const Normalization& normalization);
};
My envs:
OS:Ubuntu 20.04
gcc:9.4.0
PCL:1.13.1
Eigen:3.4.0
So I'm a bit confused about -O3flag or Release type which could make crash in two libraries. And do not make sure what cause the error.
EDIT
The program worked well after I changed Matrix typedef as below.
set Matrix with Eigen::DontAlign
/// Our base matrix class.
typedef Eigen::Matrix<double, -1, -1, Eigen::DontAlign> Matrix;
/// Typedef for our specific type of vector.
typedef Eigen::Matrix<double, -1, 1, Eigen::DontAlign> Vector;
/// Typedef for an index vector, used to index other matrices.
typedef Eigen::Matrix<Matrix::Index, Eigen::Dynamic, 1> IndexVector;
/// Typedef for our specific type of array.
typedef Eigen::Array<double, -1, 1, Eigen::DontAlign> Array;
But it seems would cost more, any other solutions?
I had also tried to add EIGEN_MAKE_ALIGNED_OPERATOR_NEW, but it didn't work.
Here are more details.
First, I clone the cpd repo.
Secondly, build and install
Thirdly, compile and run
I compiled the
examples/random.cpp
with my ownCMakeList.txt
,the
examples/random.cpp
:run wtih:
./random rigid 100 3
Then I got
Segmentation fault (core dumped)
What I had tried:
1、Deleted
PCL
inCMakeList.txt
compiled and ran with same command. It worked well.
2、Tried to keep
PCL
, changedCMAKE_BUILD_TYPE
and-O3
flag in cmakecompiled and ran with same command. It worked well too.
3、Tried to rebuild and reinstall cpd with
CMAKE_BUILD_TYPE=Release
.Then I ran with the same command, error occurred when I deleted
PCL
、Release
type and-O3
flag in CMake.3、Tried to other flags like
-O -O1 -O2
. They didn't work either.4、Tried to use GDB debug error occurred in
Eigen
libIt finished the main
rigid
function but copyResult
struct.My envs:
OS:Ubuntu 20.04
gcc:9.4.0
PCL:1.13.1
Eigen:3.4.0
So I'm a bit confused about
-O3
flag orRelease
type which could make crash in two libraries. And do not make sure what cause the error.EDIT
The program worked well after I changed
Matrix
typedef as below. set Matrix withEigen::DontAlign
But it seems would cost more, any other solutions?
I had also tried to add
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
, but it didn't work.