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

std::priority_queue Assertion failed

Tags: None
(comma "," separated)
TJKlein
Registered Member
Posts
7
Karma
0
Hi,

I know that there is this problem with the std::vector and Eigen Lib. Thus I am using the Eigen/StdVector header. This works fine. However, when I plug the vector into a std::priority_queue I get '_Val': formal parameter with __declspec(align('16')) won't be aligned C:\Programme\Microsoft Visual Studio 9.0\VC\include\vector'.

std::priority_queue<Frame, std::vector<Frame>, FrameComparator> _framePQ;

wheras Frame is struct containing Eigen::Matrices

Is there anything I forgot to consider? Sorry if it is a newbie problem.


Regards,
Tassilo

Last edited by TJKlein on Wed Jul 01, 2009 7:11 am, edited 1 time in total.
User avatar
bjacob
Registered Member
Posts
658
Karma
3
What version of Eigen?

Try replacing
Code: Select all
std::vector<Frame>

by
Code: Select all
std::vector<Frame, Eigen::aligned_allocator<Frame> >

everywhere in your code (including inside the priority_queue). If that doesn't solve the problem, I don't know. A quick look at priority_queue, here with G++ 4.4, doesn't reveal any value_type being passed by value (which is the meaning of your compiler error message). Maybe you could post here as code the content of your priority_queue header.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
User avatar
bjacob
Registered Member
Posts
658
Karma
3
Ah, and also, make sure to include Eigen/StdVector BEFORE including any relevant standard headers (like priority_queue).
TJKlein
Registered Member
Posts
7
Karma
0
Thanks a lot. I am now at least a little step further - it compiles. Unfortunately it fails an assertion and redirects me to that web-site: http://eigen.tuxfamily.org/dox/Unaligne ... ssert.html

But I checked everything that's on there and adapted it. But when pushing more than one element on the priority queue it fails that assertion.


Code: Select all
class Frame
{
public:
   int frameId;
   Eigen::Matrix4f T_image;
   Eigen::Matrix4f T_world
   float distance;
public:
   EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};

class FrameComparator
{
   bool reverse;

   public:
      FrameComparator(const bool& revparam=false)   { reverse=revparam; }
      bool operator() (const Frame& lhs, const Frame& rhs) const
      {
         if (reverse)
            return (lhs.distance < rhs.distance);
         else
            return (lhs.distance > rhs.distance);
  }
};


std::priority_queue<Frame, std::vector<Frame, Eigen::aligned_allocator<Frame> >, FrameComparator> _framePQ
Frame _tempFrame;
_framePQ.push(_tempFrame);




Regards,
Tassilo
User avatar
bjacob
Registered Member
Posts
658
Karma
3
I'm going to be away for a few days. Hope that someone else can help you. Don't forget to tell us your Eigen version. Also:

as a temporary workaround, you can replace Eigen::Matrix4f by
Code: Select all
Eigen::Matrix<float,4,4,Eigen::DontAlign>


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
TJKlein
Registered Member
Posts
7
Karma
0
Okay, thanks. Concerning the version, it is Eigen 2.0.3.

Regards,
Tassilo
User avatar
bjacob
Registered Member
Posts
658
Karma
3
ok. Another useful thing is if you can produce a good back-trace from your crash (the failed assert). It'd be interesting to see which function in which std container causes the crash (that will be a function taking a Frame by value). Is it std::vector::resize() ?


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
TJKlein
Registered Member
Posts
7
Karma
0
Okay a trace back: the assertion failed in MatrixStorage.h, Line 44

1)_framePQ.push(_tempFrame);

2) push_heap(c.begin(), c.end(), comp); @ <queue> - Line: 212

3) std::_Push_heap_0(_CHECKED_BASE(_First), _CHECKED_BASE(--_Last), _Pred,
_Dist_type(_First), _Val_type(_First)); @ <algorithm> - Line: 2045

4) std::_Push_heap(_First, _Count, _Diff(0), _Ty(*_Last), _Pred); @ <algorithm> - Line: 2033

=> Assertion failed.
User avatar
bjacob
Registered Member
Posts
658
Karma
3
4) std::_Push_heap(_First, _Count, _Diff(0), _Ty(*_Last), _Pred); @ <algorithm> - Line: 2033

=> Assertion failed.


aaah great :)

So what is the prototype of this std::_Push_heap function at algorithm:2033 ?
Does it take a Frame by value? If yes, that's another flaw in the STL (either in the standard or in the MSVC implementation). The next most useful thing is if you can produce a self-contained test-case so that we can reproduce at home.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
I tried that with MSVC 2008 and I cannot reproduce the issue.

here is what I tried:
http://pastebin.com/d73eb61a7
TJKlein
Registered Member
Posts
7
Karma
0
Okay, I will try to build a test case. So far I am working fine with the quick hack workaround.


Bookmarks



Who is online

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