[C++-sig] Re: problems with std::string (complete msg.)

Raoul Gough RaoulGough at yahoo.co.uk
Tue Dec 9 12:28:39 CET 2003


"jsseo" <jsseo at postech.ac.kr> writes:

> I'm sorry but the previous messages I sent were broken because of the
> mailing system that I use.
> Here is the original message.
>
> When I passed a string parameter that is longer than 15,
> the program hals with the following assertion failed error message.
> The error occured when I built the project for "Debug" mode.
> (compiler: Microsoft Visual Studio .NET 2003)
>
> e.g. in python interpreter,
> from ex1 import *
> e = Ex("123456789012345") <-- ok
> e = Ex("1234567890123456") <-- error
> e.name = "123456789012345" <-- ok
> e.name = "1234567890123456" <-- error
>
> the error message
> -----------------------------
> Program:c:\python22\python.exe
> File:dbgheap.c
> Line: 1132
> Expression: _CrtlsValidHeapPointer(pUserData)

Looks like heap corruption to me. It could be that the slightly longer
string requires a new memory (re)allocation internal to the
std::string object, which only then detects a corruption that occured
earlier. This could be due to almost anything, of course. Can you
reproduce the problem using straight C++? Might be easier to track
down that way. You mind find some kind of memory leak or
write-past-the-end detection code useful (e.g.
http://dmalloc.com/). Slightly off-topic here I guess, since it seems
likely to be a straight old C++ problem.

-- 
Raoul Gough.
export LESS='-X'





More information about the Cplusplus-sig mailing list