Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
|
07-09-2004 07:23
I have the following code snippet: if( ReadBuffer[0] == '<' ) { Debug( "XML IPC received from client [%s]\n", ReadBuffer ); TiXmlDocument IPC; IPC.Parse( ReadBuffer );
ProcessXMLInput( IPC ); cout << "done processing xml input" << endl; } else { Debug( "Legacy IPC received from client [%s]\n", ReadBuffer ); } cout << "marker b" << endl;
When it runs, mostly it works, but every so often, we get the line "done processing xml input" and then there's a runtime error before it gets to "marker b". I assume the stack is corrupted but cant localize whereabouts (presumably in that function ProcessXMLInput(), but there's more than a few lines in that). Does anyone know of any utilities that would help with this kind of problem? I'mthinking if there's some way of dumping the current stack, like outside an Exception, then I can just dump the stack every few lines and visually inspect where it goes wrong. What do you think? Azelda
|
Francis Chung
This sentence no verb.
Join date: 22 Sep 2003
Posts: 918
|
07-09-2004 09:12
Well, without knowing anything about your environment or the rest of the code, I can't begin to guess where the problem might be, or any tools that might help you isolate memory overruns.
One suggestion that I should make, though, is that you should flush the output buffer to isolate these kinds of messes.
You might find that your runtime occurs later than "marker b".
Background for others that might be reading:
The ostream class (which cout is an instance of) provides a buffered output. It's usually buffered for performance reasons. So, you can flush your buffers by saying cout.flush(); Otherwise, you might find that you've actually called the "cout" code, but the output just didn't make it to your console before your program crashed.
_____________________
-- ~If you lived here, you would be home by now~
|
Carnildo Greenacre
Flight Engineer
Join date: 15 Nov 2003
Posts: 1,044
|
07-09-2004 22:56
If you're developing under Linux, you can try the Valgrind memory debugger. Alternately, you could try assembler-level debug tracing in Microsoft Visual Studio (assuming they haven't dropped that feature).
_____________________
perl -le '$_ = 1; (1 x $_) !~ /^(11+)\1+$/ && print while $_++;'
|