Registered Member
|
I've been trying to track down a frustrating segfault which seems to be triggered within Eigen code, called from the following function:
(The function is used for a Python binding for part of Eigen, if you're wondering). I'm guessing the bug is fairly sensitive to how the compiler chooses to align the code in memory, since I only get it using GCC 4.7 (other versions of GCC seem OK, as well as MSVC and Clang). I also get similar segfaults in a couple other places, but they go away when compiling in debug mode - this particular instance was the only one that seemed to persist in release/debug. I'm using Eigen 3.1.1. The Interval class is pretty simple (an range between two numbers, represented as two doubles) and allows implicit construction from a double; if it matters, here are the Eigen templates that I have specialized for it: EDIT: MatrixXI is, as you might have guessed, a typedef for Matrix<Interval, Dynamic, Dynamic>.
I've also attached the stack trace from the debugger below, and the output when running the code through Valgrind, if that helps. Any thoughts? Stack trace:
Valgrind output:
|
Moderator
|
hi, the issue seems to be in our default cast implementation which is performing a static_cast, in your case:
return static_cast<Interval>(x); where x is a double. What if your specialize for your type as follow:
|
Moderator
|
hm, sorry the previous suggestion won't change anything. I think the problem is on the matrix passed to the rmulXdI function which seems invalid as reported by valgrind:
Address 0x574ffd is not stack'd, malloc'd or (recently) free'd |
Registered Member
|
Hmm, OK, I'll check that matrix to see if it's suspect somehow. And yes, I noticed the static_cast and wasn't sure about it but all the C++ documentation I read said that it should be fine (i.e., it'll call conversion constructors if necessary). Thanks for taking the time to look into it - I'll let you know what I find... |
Registered users: Baidu [Spider], Bing [Bot], Google [Bot], Yahoo [Bot]