c++.stl.port - Crashes while deallocating local strings
- Richard Haney (44/44) Mar 20 2004 I have been having crashes when my functions are deallocating strings be...
- Richard Haney (4/8) Mar 21 2004 ...
- Richard Haney (7/11) Mar 22 2004 ...
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 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; } ..
Mar 20 2004
Correction to problem statement: In article <c3j1sm$2o4c$1 digitaldaemon.com>, Richard Haney says...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.... Of course, the string constructor used is _not_ the copy constructor.
Mar 21 2004
Correction and solution -- In article <c3j1sm$2o4c$1 digitaldaemon.com>, Richard Haney says...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.... A correction to this problem statement can be found at <http://www.digitalmars.com/drn-bin/wwwnews?c%2B%2B.stl.port/183> And a solution along with some discussion can be found at <http://www.digitalmars.com/drn-bin/wwwnews?c%2B%2B.stl.port/185>
Mar 22 2004