Problem when disabling checked iterators in vs2008 SP1 (_HAS_ITERATOR_DEBUGGING = 0)

I am having problems running vs2008 SP1 in debug mode when I try to disable checked iterators. The following program reproduces the problem (failure in the line descriptor):

#define _HAS_ITERATOR_DEBUGGING 0 #include <sstream> int do_stuff(std::string const& text) { std::string::const_iterator i(text.end()); return 0; } int main() { std::ostringstream os; os << "some_text"; return do_stuff(os.str()); } 

I found a similar post on gamdev.net that discussed this issue in vs2005. The sample program in this post compiles for me in 2008 Service Pack 1 (SP1) as it is, but when I modified it to use ostringstream, I was able to get the problem.

From pushing in the debugger, it looks like the library is pushing iterators out of the stack and then trying to use them in _Orphan_All, which is some kind of iterator check cleaning code ...

Can anyone else reproduce this problem or tell me what is going on?

Thanks!

+7
c ++ iterator debugging visual-studio-2008 crash
source share
4 answers

I just tried this on VS2008 on Windows XP and received a warning about buffer overflows on both the preliminary and post-SP1 VS2008.

Interestingly, the problem seems to be centered around passing the string to do_stuff either by reference or by value - if I use the source code, it complains about buffer overflow, but if I pass the string by value, it works fine. This is due to multi-threaded debugging DLL. The error disappears when you like the static MT Debug environment.

In both cases, the precompiled headers were turned off, and the files that usually generate precompiled headers were removed from the project.

After reading this article on MSDN, I’m wondering if the problem arises because several classes of the C ++ standard library are actually in if you create using the debug time of the DLL (just try linking the binary generated by VS2008 to an earlier library and monitor unauthorized external files to confirm this).

+6
source share

This seems to be a known bug in VS2005, which was fixed in VS2005 SP1:

It looks like it was submitted by the guy who posted it on gamedev.net.

I'm not sure how and why it returned to VS2008 (do you have VS2005 headers that might be in the way or something else?)

+4
source share

Your code works fine in debug / release mode on my VS2005. I disabled the precompiled headers and used the multi-threaded DLL version of the runtime library.

Tested with VS2008 SP1 on a Vista computer (no precompiled headers, multi-threaded DLL). Works great.

Check your installation.

+1
source share

I reported a problem on the Microsoft website. They acknowledged the error and said they fixed it for the next version.

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=435483

+1
source share

All Articles