Program crash during doexit()

This topic is 4844 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

So, I've been working on a game for a while and decided to use some XML files as input to the game. Typical stuff. I choose Tinyxml and simply include the tinyxml files into my VC7.0 project and re-compile. Easy pickings! However, now my program always crashes on exit. Here's the stack:
 	ntdll.dll!77f51baa()
ntdll.dll!77f7561d()
>	msvcr71d.dll!_lock_file(void * pf=0x7c38b508)  Line 236	C
msvcr71d.dll!fclose(_iobuf * stream=0x7c38b508)  Line 56 + 0x9	C
MyProgram.exe!_main()  + 0x1b5	C
msvcr71d.dll!doexit(int code=0, int quick=0, int retcaller=0)  Line 376	C
msvcr71d.dll!exit(int code=0)  Line 303 + 0xd	C
MyProgram.exe!_main()  + 0xe4	C
MyProgram.exe!mainCRTStartup()  Line 398 + 0x11	C
kernel32.dll!77e8141a()


I'm also using SDL. I have not opened any XML files or done anything with tinyxml yet. I simply compiled tinyxml into my program and added #include "tinyxml.h". But msvcr71d.dll!fclose is trying to close a stream with stream->_ptr that is null. Voila trap! stream->_flag is set to _IOWRT (2). Anyone else solve any problem with doexit crashes? I have no idea what's going on here... Cheers! Neil

Share on other sites
Write up a little hello world program that includes tinyxml and see if it does the same thing. It sounds more like tinyxml just happened to uncover a bug in your code when you included it, but we won't be able to tell for sure until you test it out on some other programs.

Share on other sites
Quote:
 Original post by bytecoderWrite up a little hello world program that includes tinyxml and see if it does the same thing. It sounds more like tinyxml just happened to uncover a bug in your code when you included it, but we won't be able to tell for sure until you test it out on some other programs.

Thanks bytecoder. Yes, I tried that. A simple C++ program which includes tinyxml doesn't crash like this. Also, when I load an XML file in this program, it all works fine.

I think you're right that a problem with my code is being exposed here. I don't understand why including tinyxml.h would make a change in codepath and expose a problem...

Since stream->_flag == _IOWRT, I assume that this is a real file stream. But I'm not yet reading in any files...

In my program, I have put exit( 0 ) at the beginning of main() so that no dynamic allocations are made (and certainly no files are loaded). I still get the crash during doexit.

Share on other sites
It sounds like something with SDL maybe. SDL does fopen and fclose the two output files. However, I think we need to see some code to get an idea to help. How about the deinitialization code? Also, was this happening before you added in the TinyXML?

Share on other sites
Apparently, this project uses both sdl and tinyxml successfully with VisualC++ 7.1. You might want to try making a simple little SDL + tinyxml program and see if that works, too.

• 10
• 16
• 14
• 18
• 15