Jump to content
  • Advertisement
Sign in to follow this  
hiigara

[Visual C++] App crashing in ostringstream constructor!

This topic is 2611 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My application is crashing during exit, when I close the main window. "Access violation". It crashes in this line:

ostringstream Debugmsg ;


This line of code is called inside the destructor of a global object.

here is the assembly


ostringstream Debugmsg ;
0050B738 mov esi,esp
0050B73A push 1
0050B73C push 2
0050B73E lea ecx,[Debugmsg]
0050B744 call dword ptr [__imp_std::basic_ostringstream<char,std::char_traits<char>,std::allocator<char> >::basic_ostringstream<char,std::char_traits<char>,std::allocator<char> > (5E1D9Ch)]
0050B74A cmp esi,esp
0050B74C call @ILT+20775(__RTC_CheckEsp) (48B12Ch)
0050B751 mov dword ptr [ebp-4],0


When I step in the above assembly code it crashes exactly in line 0050B744
Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
I found the problem.
This seems to be a static initialization/destruction fiasco problem:
http://www.gamedev.net/topic/486700-crash-during-destructor/


I have to allocate my object on the heap. Still this is bad design from STL. A library should not depend on static global objects. It should provide an init() and deinit() methods.

Another google hit:
http://www.eggheadcafe.com/microsoft/VC-Language/32623081/vc2008-stl-access-violation-depending-on-runtime-library-being----used--bug-or-undefined-behavior.aspx

Share this post


Link to post
Share on other sites
What IDE are you using? The OP of that EggheadCafe link you posted created this bug report. Microsoft responses indicate the bug was fixed in MSVC 2010 beta.

Share this post


Link to post
Share on other sites

What IDE are you using? The OP of that EggheadCafe link you posted created this bug report. Microsoft responses indicate the bug was fixed in MSVC 2010 beta.



Microsoft Visual Studio 2008
Version 9.0.21022.8 RTM
Microsoft .NET Framework
Version 3.5 SP1

Installed Edition: VC Express

Share this post


Link to post
Share on other sites
Well, there you go. The bug report is for MSVC 2008, and they say they fixed it for MSVC 2010.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!