OgreRenderer crash in destroySystem()

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

slake_jones
Just popping in
Just popping in
Posts: 4
Joined: Fri Oct 16, 2009 11:08

OgreRenderer crash in destroySystem()

Postby slake_jones » Fri Oct 16, 2009 11:36

Hi I am new to CEGUI and I would like to say that it rocks! I searched the forums and could not find an answer so I am sorry if this has already been asked.

OgreRenderer::destroySystem() crashes when called. The code below shows how I am using the OgreRenderer:

Code: Select all

    GuiEngine::GuiEngine( void )
    {
        CEGUI::OgreRenderer &renderer = CEGUI::OgreRenderer::bootstrapSystem();
        //CEGUI::System::getSingleton().setScriptingModule( &CEGUI::LuaScriptModule::create() );
    }

    GuiEngine::~GuiEngine( void )
    {
        CEGUI::OgreRenderer::destroySystem();
    }


I am not sure whether I am doing something wrong or it is a bug. When stepping through the code in destroySystem() the crash happens on line 113 of CEGUIOgreRenderer.cpp which contains the following code:

Code: Select all

    OgreImageCodec* ic = &static_cast<OgreImageCodec&>(sys->getImageCodec());

    System::destroy();
    destroyOgreImageCodec(*ic);

The error happens on destroyOgreImageCodec(*ic); which intern deletes ic. I noticed that once System::destroy() is called ic no longer exists (it appears to have been freed) causing the deletion of ic to fail.

Is this a bug or have I missed out a step :?

I am grateful for any help you can give,

Slake.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: OgreRenderer crash in destroySystem()

Postby CrazyEddie » Fri Oct 16, 2009 12:23

Hi,

Presumably you're not setting the image codec to something else later on? This definitely sounds bug-like at the moment. Are you able to get a callstack / backtrace? What's the nature of the 'crash' (access violation / segfault, or something?) And can you post the indicated part in the CEGUI.log file, since it saves me asking a bunch of questions about operating systems, compilers and linking etc.. :)

CE.

slake_jones
Just popping in
Just popping in
Posts: 4
Joined: Fri Oct 16, 2009 11:08

Re: OgreRenderer crash in destroySystem()

Postby slake_jones » Fri Oct 16, 2009 12:45

Hi,

I do not altering the image codec later on. I literally only create and destroy the ogre renderer at the moment. I am using visual studio 2008 and statically linking to CEGUI.

The error is an Access violation reading location 0xfeeefeee.

Before System::destroy() is called ic contains, for example:
- CEGUI::ImageCodec {d_identifierString={...} d_supportedFormat={...} } CEGUI::ImageCodec
+ __vfptr 0x0177a260 const CEGUI::OgreImageCodec::`vftable' *
+ d_identifierString {npos=0xffffffff d_cplength=0x0000003d d_reserve=0x0000003e ...} CEGUI::String
+ d_supportedFormat {npos=0xffffffff d_cplength=0x00000000 d_reserve=0x00000020 ...} CEGUI::String

i.e. sensible values, but after System::destroy() is called and before destroyOgreImageCodec(*ic) is called ic contains:
- CEGUI::ImageCodec {d_identifierString={...} d_supportedFormat={...} } CEGUI::ImageCodec
+ __vfptr 0xfeeefeee *
+ d_identifierString {npos=0xffffffff d_cplength=0xfeeefeee d_reserve=0xfeeefeee ...} CEGUI::String
+ d_supportedFormat {npos=0xffffffff d_cplength=0xfeeefeee d_reserve=0xfeeefeee ...} CEGUI::String

which suggests System::destroy() cleans up the image codec before destroyOgreImageCodec(*ic) is called.

The actual crash is in:

Code: Select all

void OgreRenderer::destroyOgreImageCodec(OgreImageCodec& ic)
{
    delete &ic;
}

when delete &ic; is called.

My log file is,

Code: Select all

16/10/2009 13:29:35 (Std)    ********************************************************************************
16/10/2009 13:29:35 (Std)    * -------- START OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM       -------- *
16/10/2009 13:29:35 (Std)    ********************************************************************************
16/10/2009 13:29:35 (Std)    ---- Version 0.7.0 (Build: Oct 15 2009 Static Debug Microsoft Windows MSVC++ 9.0 32 bit) ----
16/10/2009 13:29:35 (Std)    ---- Renderer module is: CEGUI::OgreRenderer - Official OGRE based 2nd generation renderer module. ----
16/10/2009 13:29:35 (Std)    ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
16/10/2009 13:29:35 (Std)    ---- Image Codec module is: OgreImageCodec - Integrated ImageCodec using the Ogre engine. ----
16/10/2009 13:29:35 (Std)    ---- Scripting module is: None ----
16/10/2009 13:29:35 (Std)    ********************************************************************************
16/10/2009 13:29:35 (Std)    * -------- END OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM         -------- *
16/10/2009 13:29:35 (Std)    ********************************************************************************


Once again, thanks for the help and the cool GUI system :D

Slake.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: OgreRenderer crash in destroySystem()

Postby CrazyEddie » Fri Oct 16, 2009 12:57

Thanks for the extra info. Seems like it's a double-deletion bug, possibly related to the way things are handled differently in statically linked mode. I'll confirm to be sure this and get it fixed - thanks :D

Once again, thanks for the help and the cool GUI system :D

NP. Glad you like CEGUI - bugs aside, of course ;)

CE.

slake_jones
Just popping in
Just popping in
Posts: 4
Joined: Fri Oct 16, 2009 11:08

Re: OgreRenderer crash in destroySystem()

Postby slake_jones » Mon Oct 19, 2009 11:22

CrazyEddie wrote:Thanks for the extra info. Seems like it's a double-deletion bug, possibly related to the way things are handled differently in statically linked mode. I'll confirm to be sure this and get it fixed - thanks :D


Once again thanks for the help,

Slake.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: OgreRenderer crash in destroySystem()

Postby CrazyEddie » Tue Oct 20, 2009 08:40

Just to confirm, this issue should now be fixed. Although be aware if you've not already taken steps to update to the new static runtime based dependency package (and so have resolved config issues), you may find you have some issues to resolve (i.e. all our statically linked parts are now using the /MT(d) options, whereas Ogre is not - so there are potential issues that exist and their resolution is left as an exercise for the user ;)

CE.

slake_jones
Just popping in
Just popping in
Posts: 4
Joined: Fri Oct 16, 2009 11:08

Re: OgreRenderer crash in destroySystem()

Postby slake_jones » Wed Oct 21, 2009 11:47

CrazyEddie wrote:Just to confirm, this issue should now be fixed.

CE.


Awesome :D

CrazyEddie wrote: you may find you have some issues to resolve (i.e. all our statically linked parts are now using the /MT(d) options, whereas Ogre is not - so there are potential issues that exist and their resolution is left as an exercise for the user ;)
CE.


Cheers for the heads up, we are setting ensuring that all dependencies are compiled with /MT(d). We intend to statically link to Ogre when 1.7 is released (because of the MIT license) so we will have more control then.

Cheers for the help,

Slake.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 3 guests