Stack Overflow crash while inserting in std::map after migration to VS2005 (VC8)
This is a multi-part message in MIME format.
------=_NextPart_000_0025_01C8094C.CE0D6D10
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Environment: Windows 2003 Server SP 2. VS 2005 Team Edition SP 1
Hello,
I keep getting these crashes - First-chance exception at 0x1057b4eb =
(Std32.dll) in TransService.exe: 0xC00000FD: Stack overflow.
This has started happening ever since we migrated to VC8 (VS2005). The =
crashes occur randomly when inserting in std::map containers, such as
std::map<string, CMyClass1 >, std::map<enumType, CMyClass2 >, etc.
This is a multithreaded application spawning about 20 threads; all doing =
the same thing. There is no problem when the program is run in a 'single =
thread' (.sln is compiled with /MD option)/ There is no problem when the =
program is compiled in XP and run on an XP system 'multi-threaded'. When =
stack overflow occurs (due to recursion - note - there are handly 10/15 =
elements in the container and I even increased the size of stack to over =
8MB.)
Can anyone suggest a solution, what could be the problem?
Any pointers would be of great help.
Thanks and Regards
Ganga
This is my code:
class CMyClass
{
Private:
std::map<eType1, CMyClass1 > con;
public:
CMyClass();
CMyClass(const CMyClass& rhs);
const CMyClass& operator=(const CMyClass& rhs);
};
class CMyClass1
{
private:
std::map<string, CMyClass2 > con;
public:
CMyClass1();
CMyClass1(const CMyClass1& rhs);
const CMyClass1& operator=(const CMyClass1& rhs);
}
Copy constructor CMyClass:: CMyClass(const CMyClass& rhs){*this = =
rhs;)
const CMyClass& CMyClass ::operator=(const CMyClass& rhs)
{
If(this == &rhs) return;
//crash in executing code below
con.clear();
//con = rhs.con; //this was working fine with =
VS2003 VC7.x
for(std::map<eType1, CMyClass1 >::const_iterator It = =
rhs.con.begin(); It != rhs.con.end(); It++)
{
//con[(*It).first] = (*It).second);
// con.insert(rhs.con.end(), make_pair((*It).first, (*It).second));
con.insert(make_pair((*It).first, =
(*It).second));
}
}
The call stack is as below (from real output)
=
Std32.dll!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_t=
raits<char>,std::allocator<char> =
,CDeclarationInfo,std::less<std::basic_string<char,std::char_traits<char=
,std::allocator<char> > =
,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,=
std::allocator<char> > const ,CDeclarationInfo> >,0> =
::_Erase(std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::ch=
ar_traits<char>,std::allocator<char> =
,CDeclarationInfo,std::less<std::basic_string<char,std::char_traits<char=
,std::allocator<char> > =
,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,=
std::allocator<char> > const ,CDeclarationInfo> >,0> >::_Node * =
_Rootnode=0x091a5f40) Line 1073 + 0x12 bytes C++
=
Std32.dll!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_t=
raits<char>,std::allocator<char> =
,CDeclarationInfo,std::less<std::basic_string<char,std::char_traits<char=
,std::allocator<char> > =
,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,=
std::allocator<char> > const ,CDeclarationInfo> >,0> =
::_Erase(std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::ch=
ar_traits<char>,std::allocator<char> =
,CDeclarationInfo,std::less<std::basic_string<char,std::char_traits<char=
,std::allocator<char> > =
,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,=
std::allocator<char> > const ,CDeclarationInfo> >,0> >::_Node * =
_Rootnode=0x091a5f40) Line 1076 C++
=
Std32.dll!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_t=
raits<char>,std::allocator<char> =
,CDeclarationInfo,std::less<std::basic_string<char,std::char_traits<char=
,std::allocator<char> > =
,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,=
std::allocator<char> > const ,CDeclarationInfo> >,0> =
::_Erase(std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::ch=
ar_traits<char>,std::allocator<char> =
,CDeclarationInfo,std::less<std::basic_string<char,std::char_traits<char=
,std::allocator<char> > =
,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,=
std::allocator<char> > const ,CDeclarationInfo> >,0> >::_Node * =
_Rootnode=0x091a5f40) Line 1076 C++
=
Std32.dll!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_t=
raits<char>,std::allocator<char> =
,CDeclarationInfo,std::less<std::basic_string<char,std::char_traits<char=
,std::allocator<char> > =
,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,=
std::allocator<char> > const ,CDeclarationInfo> >,0> =
::_Erase(std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::ch=
ar_traits<char>,std::allocator<char> =
,CDeclarationInfo,std::less<std::basic_string<char,std::char_traits<char=
,std::allocator<char> > =
,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,=
std::allocator<char> > const ,CDeclarationInfo> >,0> >::_Node * =
_Rootnode=0x091a5f40) Line 1076 C++
------=_NextPart_000_0025_01C8094C.CE0D6D10
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; =
charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16525" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV>
<DIV class=Section1>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Environment: Windows 2003 =
Server SP
2. VS 2005 Team Edition SP 1<?xml:namespace prefix = o ns =
"urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p>Hello,</o:p></SPAN></P>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">I keep
getting these crashes - First-chance exception at 0x1057b4eb (Std32.dll) =
in
TransService.exe: 0xC00000FD: Stack overflow.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">This has
started happening ever since we migrated to VC8 (VS2005). The crashes =
occur
randomly when inserting in std::map containers, such =
as<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">std::map<string, =
CMyClass1 >,
std::map<enumType, CMyClass2 >, etc.</SPAN></P>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT
face=Arial>This is a multithreaded application spawning about 20 =
threads;
all doing the same thing. There is no problem when the program is run in =
a
=91single thread' (.sln is compiled with /MD option)/ There is no =
problem when the
program is compiled in XP and run on an XP system =91multi-threaded'. =
When stack
overflow occurs (due to recursion - note =96 there are handly 10/15 =
elements in
the container and I even increased the size of stack to over
8MB.)</FONT></SPAN></SPAN></P>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT =
face=Arial>Can anyone
suggest a solution, what could be the problem?</FONT></SPAN></SPAN></P>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT =
face=Arial>Any
pointers would be of great help.</FONT></SPAN></SPAN></P>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT =
face=Arial>Thanks and
Regards</FONT></SPAN></SPAN></P>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT
face=Arial>Ganga</FONT></SPAN></SPAN></P>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT =
face=Arial>This is my
code:<o:p></o:p></FONT></SPAN></P><o:p></o:p></SPAN>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p> </o:p></SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">class =
CMyClass<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">{<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">Private:<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
std::map<eType1, CMyClass1 > con;<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">public:<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
CMyClass();<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
CMyClass(const CMyClass& rhs);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
const CMyClass& operator=(const CMyClass& =
rhs);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">};<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">class
CMyClass1<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">{<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">private:<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
std::map<string, CMyClass2 > con;<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">public:<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
CMyClass1();<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
CMyClass1(const CMyClass1& rhs);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
const CMyClass1& operator=(const CMyClass1& =
rhs);<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">}<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">Copy
constructor CMyClass:: CMyClass(const CMyClass& rhs){*this =
rhs;)<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">const
CMyClass& CMyClass ::operator=(const CMyClass&
rhs)<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">{<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
If(this == &rhs) return;<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
//crash in executing code below<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
con.clear();<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
//con =
rhs.con;  =
;
//this was working fine with VS2003 VC7.x<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
for(std::map<eType1, CMyClass1 >::const_iterator It = =
rhs.con.begin(); It
!= rhs.con.end(); It++)<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 1in"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">//con[</SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT
face=Arial>(*It).first] = =
(*It).second);<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN-LEFT: 0.5in; TEXT-INDENT: =
0.5in"><FONT
face=Arial><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">//</SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> con.insert(rhs.con.end(), =
</SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier =
New'">make_pair((*It).first,
(*It).second));<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN-LEFT: 1in"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
con.insert(</SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT
face=Arial>make_pair((*It).first, =
(*It).second));<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT
face=Arial> =
}<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT
face=Arial>}<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal><FONT face=Arial><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier =
New'"><o:p> </o:p></SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier =
New'"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p><FONT
face=Arial> </FONT></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT =
face=Arial>The call
stack is as below (from real output)<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p><FONT
face=Arial> </FONT></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">>
Std32.dll!std::_Tree<std::_Tmap_traits<std::basic_string<char,st=
d::char_traits<char>,std::allocator<char>
>,CDeclarationInfo,std::less<std::basic_string<char,std::char_tr=
aits<char>,std::allocator<char>
>
>,std::allocator<std::pair<std::basic_string<char,std::char_t=
raits<char>,std::allocator<char>
> const ,CDeclarationInfo> >,0>
>::_Erase(std::_Tree_nod<std::_Tmap_traits<std::basic_string<=
char,std::char_traits<char>,std::allocator<char>
>,CDeclarationInfo,std::less<std::basic_string<char,std::char_tr=
aits<char>,std::allocator<char>
>
>,std::allocator<std::pair<std::basic_string<char,std::char_t=
raits<char>,std::allocator<char>
> const ,CDeclarationInfo> >,0> >::_Node *
_Rootnode=0x091a5f40) Line 1073 + 0x12
bytes =
C++<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
Std32.dll!std::_Tree<std::_Tmap_traits<std::basic_string<char,st=
d::char_traits<char>,std::allocator<char>
>,CDeclarationInfo,std::less<std::basic_string<char,std::char_tr=
aits<char>,std::allocator<char>
>
>,std::allocator<std::pair<std::basic_string<char,std::char_t=
raits<char>,std::allocator<char>
> const ,CDeclarationInfo> >,0>
>::_Erase(std::_Tree_nod<std::_Tmap_traits<std::basic_string<=
char,std::char_traits<char>,std::allocator<char>
>,CDeclarationInfo,std::less<std::basic_string<char,std::char_tr=
aits<char>,std::allocator<char>
>
>,std::allocator<std::pair<std::basic_string<char,std::char_t=
raits<char>,std::allocator<char>
> const ,CDeclarationInfo> >,0> >::_Node *
_Rootnode=0x091a5f40) Line 1076
C++<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
Std32.dll!std::_Tree<std::_Tmap_traits<std::basic_string<char,st=
d::char_traits<char>,std::allocator<char>
>,CDeclarationInfo,std::less<std::basic_string<char,std::char_tr=
aits<char>,std::allocator<char>
>
>,std::allocator<std::pair<std::basic_string<char,std::char_t=
raits<char>,std::allocator<char>
> const ,CDeclarationInfo> >,0>
>::_Erase(std::_Tree_nod<std::_Tmap_traits<std::basic_string<=
char,std::char_traits<char>,std::allocator<char>
>,CDeclarationInfo,std::less<std::basic_string<char,std::char_tr=
aits<char>,std::allocator<char>
>
>,std::allocator<std::pair<std::basic_string<char,std::char_t=
raits<char>,std::allocator<char>
> const ,CDeclarationInfo> >,0> >::_Node *
_Rootnode=0x091a5f40) Line 1076
C++<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
Std32.dll!std::_Tree<std::_Tmap_traits<std::basic_string<char,st=
d::char_traits<char>,std::allocator<char>
>,CDeclarationInfo,std::less<std::basic_string<char,std::char_tr=
aits<char>,std::allocator<char>
>
>,std::allocator<std::pair<std::basic_string<char,std::char_t=
raits<char>,std::allocator<char>
> const ,CDeclarationInfo> >,0>
>::_Erase(std::_Tree_nod<std::_Tmap_traits<std::basic_string<=
char,std::char_traits<char>,std::allocator<char>
>,CDeclarationInfo,std::less<std::basic_string<char,std::char_tr=
aits<char>,std::allocator<char>
>
>,std::allocator<std::pair<std::basic_string<char,std::char_t=
raits<char>,std::allocator<char>
> const ,CDeclarationInfo> >,0> >::_Node *
_Rootnode=0x091a5f40) Line 1076
C++<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"> =
<o:p></o:p></SPAN></P></DIV></DIV></BODY></HTML>
------=_NextPart_000_0025_01C8094C.CE0D6D10--