| |
| Posted by Richard Haney | PermalinkReply |
|
Richard Haney
| I have been having crashes when my functions are deallocating strings before returning to the calling function. In the latest instance the function has five local strings initialized to literals via the copy constructor, and the parameter list consists of four "string::iterator&" parameters.
I've traced the execution via the Assembly window of the IDDE debugger to the
fifth (last) call into "std::basic_string<>::~basic_string<>()", past the call
to "std::_Destroy", into "std::_String_base<>::~_String_base<>()", into
"std::_String_base<>_M_deallocate_block()", then into
"allocator<>::deallocate(char *, unsigned) const" and then into
"std::_new_alloc::deallocate(void *,unsigned )", then into "std::__stl_delete"
and then to a call to some literal address where the call is apparently a part
of the assembly expansion of "inline void _STLP_CALL __stl_delete(void* __p) {
::operator delete(__p) }". From that point the code is pure machine code with
symbolic ops, where it crashes somewhere there. Any attempt to step over any of
the above calls stepped into results in the crash.
I tried turning on the "enable new[], delete[]" compiler toggle for the project in case this might be needed, but the toggle does not stay on.
Does anyone have any idea why my programs are crashing like this?
Basically, my functions copy and edit characters from one string using a pair of passed string::iterator& parameters to store into another string via another pair of string::iterator& parameters. Here is an example of code from the current instance:
void
e_heading::cleanUp(
string::iterator& scan,
string::iterator& end_scan,
string::iterator& outBegin,
string::iterator& outScan){
string lt = "<";
string gt = ">";
string singl_quot = "'";
string doubl_quot = """;
string ampersand = "&";
// while not an html tag
while(scan != end_scan && *scan != '<'){
*outScan = *scan;
// translate html < and >
if(equal(lt.begin(),lt.end(),scan) ){
*outScan = '<';
// note:
// extra increment will be added uniformly at end of loop
scan +=3;
}
..
|