This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Segmentation fault

Tags: None
(comma "," separated)
agadre
Registered Member
Posts
2
Karma
0

Segmentation fault

Fri Nov 09, 2012 10:12 pm
Hi,

I am new to the Eigen library and have a question about a segmentation fault I am getting. I have a class method that does certain computations. When I run the code however, it crashes with a segmentation fault. The method called is

void CrossTrack::iterateCrossTrack(const VectorXd& x, Vector3d& vr, Vector3d& omga, Vector3d& mxtrac)

and takes x as input and updates vr, omega and mxtrac after doing certain computations. The segmentation fault occurs at the very end of the method.

//-- METHOD BODY
// output
vr = VR;
omga = omega;
mxtrac = M_CrossTrack; // THIS IS WHERE SEGFAULT OCCURS
} // END OF METHOD

If I comment out the last line (// mxtrac = M_CrossTrack), then the segfault occurs at (omga = omega). This segfault seems to be related to alignment but I am not very knowledgeable about that aspect of Eigen. As per documentation, I have added

public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW

to the class since it contains fixed size vectors and matrices.

The relavent part of the gdb trace is as follows:

#0 0xb615ecf6 in free () from /lib/libc.so.6
#1 0xb6a3fbd7 in handmade_aligned_free (ptr=<optimized out>) at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:116
#2 aligned_free (ptr=<optimized out>) at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:246
#3 conditional_aligned_free<true> (ptr=<optimized out>) at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:312
#4 conditional_aligned_delete_auto<double, true> (ptr=<optimized out>, size=<optimized out>)
at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:438
#5 ~DenseStorage (this=<optimized out>, __in_chrg=<optimized out>)
at /usr/include/eigen3/Eigen/src/Core/DenseStorage.h:278
#6 ~PlainObjectBase (this=<optimized out>, __in_chrg=<optimized out>)
at /usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:65
#7 ~Matrix (this=<optimized out>, __in_chrg=<optimized out>) at /usr/include/eigen3/Eigen/src/Core/Matrix.h:140
#8 auv::controller::CrossTrack::iterateCrossTrack (this=0x895fe660, x=..., vr=..., omga=..., mxtrac=...)
at /home/agadre/src/thruster/thruster-libauv/src/lib/auv/controller/CrossTrack.cpp:316
#9 0xb6a40a8f in auv::controller::CrossTrack::iterate (this=0x810a700)

I will certainly appreciate any input in this regard.

Thanks!
agadre
Registered Member
Posts
2
Karma
0

Re: Segmentation fault

Sat Nov 10, 2012 3:08 am
An update on this segmentation fault. I forgot to mention that I was using RelWithDebInfo build from CMake, which basically has "-g -O2" flags. This segmentation fault does not occur if instead I use "Debug" build, with "-g -O0" option. I am wondering if the optimization is causing any weird behavior.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Segmentation fault

Sat Nov 10, 2012 1:38 pm
it's impossible to help you without the full function code.
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS

Re: Segmentation fault

Sat Nov 10, 2012 2:47 pm
Without knowing anything about this case in specific, getting crashes depending on what compiler flags are being used sounds like subtle memory management errors or similar in your code. Try running it trough valgrind and fix anything it tells you, that'll probably help.

Greetings,
Sven


I'm working on the KDevelop IDE.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]