Menu

STL doc.SaveFile error using /MDd

Developer
George
2006-07-11
2013-05-20
  • George

    George - 2006-07-11

    I get an error debugging when calling doc.SaveFile( filename ) using Multi-threaded Debug DLL (/MDd) but not when using /MTd.

    I can avoid this error by passing SaveFile filename.c_str() rather than the std::string.

    The debug error is:
    Debug Assertion Failed!
    Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)

    The callstack points to:
    TiXmlBase::StringToBuffer::~StringToBuffer()
    {
    ->  delete [] buffer;
    }

    I use:
    VC8 Express & PlatformSDK_Svr2003R2_rtm

     
    • George

      George - 2006-07-11

      I think I may have found the problem, and should probably share it to benefit humanity :).

      It is a conflict with Ogre and I also have a work around that works perfectly for me and makes some sense.

      Any project that uses Ogre includes the <Ogre.h> header and automatically uses the Ogre memory manager (see  ogrememorymanager.h). The Ogre memory manager allocates all memory within the OgreMain.dll providing a central place to debug memory usage.

      The problems with tinyXML occur when the library tinyxmld_STL.lib or whichever one is built without Ogre and then used in a project that does use Ogre.

      The errors occur whenever data is deleted by one process that was created in another. This is possible since the compiled code in the tinyxml library allocates & frees memory without using Ogre. BUT, compiled code in the main project uses Ogre to allocates & free memory. When memory is allocated in one process or dll and attempted to be freed in another this results in the debug error: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) and the debugger will often point to a 'delete [] buf;' or similar line.

      A simple workaround is to add #include <Ogre.h> to the top of "tinyXML.h" before building the tiny xml library. This will result in an Ogre friendly version of the tinyxml library.

       

Log in to post a comment.