map insert cause crash, please look

L

linq936

Hi,
I have a simple code like this,

int NodeRepo::storeNode(MyString key, MyNode* node){
this->nodeMap.insert(make_pair(key, node));

return 0;
}


In class MyString, there is operator < defined.

But the problem crashes when it comes to this function on Windows. I
launtch the VC debugger, I can see that the 2 arguments of the function
are all right, I checked their values.

The crash comes from some code in STL, make_pair() does return some
value, and then it comes to this STL function,

template <class _Key, class _Value, class _KeyOfValue,
class _Compare, class _Alloc> pair< _Rb_tree_iterator<_Value,
_Nonconst_traits<_Value> >, bool>
_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> ::insert_unique(const
_Value& __v)
{
_Link_type __y = this->_M_header._M_data;
...
}

The crash is because this->_M_header is pointing to some garbage.

I am not sure what this means.

Could you give me some pointer?
 
A

Andre Kostur

Hi,
I have a simple code like this,

int NodeRepo::storeNode(MyString key, MyNode* node){
this->nodeMap.insert(make_pair(key, node));

return 0;
}


In class MyString, there is operator < defined.

But the problem crashes when it comes to this function on Windows. I
launtch the VC debugger, I can see that the 2 arguments of the function
are all right, I checked their values.

The crash comes from some code in STL, make_pair() does return some
value, and then it comes to this STL function,

template <class _Key, class _Value, class _KeyOfValue,
class _Compare, class _Alloc> pair< _Rb_tree_iterator<_Value,
_Nonconst_traits<_Value> >, bool>
_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc> ::insert_unique(const
_Value& __v)
{
_Link_type __y = this->_M_header._M_data; ...
}

The crash is because this->_M_header is pointing to some garbage.

I am not sure what this means.

Could you give me some pointer?

It means that you've FUBARed your map. Possibly because your operator<
doesn't define a strict weak ordering. Possibly because you've done
something else wrong in your program that has put your map into an
unstable state, and it's only manifesting here. We can't really tell
without more code. You need to create a minimal, compilable example that
shows the problem.. and show that to us.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,690
Latest member
MacGyver

Latest Threads

Top