map insert cause crash, please look



 DEVELOP > c-Plus-Plus > map insert cause crash, please look

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: ""
Date: 05 Jun 2006 05:44:52 PM
Object: map insert cause crash, please look
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?
.

User: "Andre Kostur"

Title: Re: map insert cause crash, please look 05 Jun 2006 05:56:05 PM
On Mon, 05 Jun 2006 15:44:52 -0700, linq936 wrote:

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.
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER