[Solved] Strange release-only issue.

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

User avatar
Nickenstein79
Quite a regular
Quite a regular
Posts: 93
Joined: Thu May 09, 2013 06:19

[Solved] Strange release-only issue.

Postby Nickenstein79 » Thu Jun 12, 2014 02:52

Hi,

I've recently built CEGUI from source (v0-8 stable branch), and I'm using it with Ogre1.9 (also built from the latest stable code). I'm currently using Windows8.1 and MSVC2010.
(I've migrated all of my data after building the latest stable ceed source, and made a few updates to the wiki on that subject to help others in future.)

The good news: Everything is working GREAT in a debug build! :)
However I get a crash on initialising CEGUI with a release build.

I have managed to trace this crash, by linking the release version of my game with the debug CEGUI libs.

The problem seems to be that in a 'Release' build, the following piece of CEGUI struct initialisation code isn't happening correctly:

Code: Select all

// Implementation data for the OgreRenderer
struct OgreRenderer_impl :
    public AllocatedObject<OgreRenderer_impl>
{
    OgreRenderer_impl() :
        d_displayDPI(96, 96),
        // TODO: should be set to correct value
        d_maxTextureSize(2048),
        d_ogreRoot(Ogre::Root::getSingletonPtr()),           <----------- This is failing somehow
        d_previousVP(0),
        d_activeBlendMode(BM_INVALID),



It seems that the d_OgreRoot variable should be getting correctly set when the 'OgreRenderer_impl' structure is malloc'ed. But the checkOgreInitialised() test is failing in the OgreRenderer() constructor, as d_ogreRoot is still a NULL pointer.




But here is the really strange part:

Code: Select all

   // CEGUI SETUP /////////////////////

   if (!Ogre::Root::getSingletonPtr())         <----- If this fails,I shouldn't reach the OgreRenderer::bootstrapSystem() call. But it passes.
      exit(0);

   // Start CEGUI
   CEGUI::OgreRenderer &CEGUI_Ogre_Renderer_Ref = CEGUI::OgreRenderer::bootstrapSystem();  <------ Code reaches here, so The Ogre:Root:Singleton does exist.
   CEGUI_Renderer = &CEGUI_Ogre_Renderer_Ref;
   pCEGUI_System = &CEGUI::System::getSingleton();
   pCEGUI_Context = &pCEGUI_System->getDefaultGUIContext();
   pCEGUI_WindowManager = &CEGUI::WindowManager::getSingleton();



Has anyone else experienced this issue?
(I can work around it by manually setting d_ogreRoot in the CEGUI source myself before/inside the checkOgreInitialised() call. I'm just really curious why the structure initialiser is failing to do this itself, and only in a Release build.)
Last edited by Nickenstein79 on Fri Jun 13, 2014 19:54, edited 4 times in total.

User avatar
Nickenstein79
Quite a regular
Quite a regular
Posts: 93
Joined: Thu May 09, 2013 06:19

Re: Strange release-only issue.

Postby Nickenstein79 » Thu Jun 12, 2014 04:41

I have resolved this issue on my own system by making the following addition to 'CEGUI_0_8\cegui\src\RenderModules\Ogre\Renderer.cpp', and rebuilding everything.

Code: Select all

//----------------------------------------------------------------------------//
void OgreRenderer::checkOgreInitialised()
{
    // Get Ogre::Root::Singleton
    d_pimpl->d_ogreRoot = Ogre::Root::getSingletonPtr(); // USER:Nickenstein79 added this as it fails in the struct init in Release builds for some reason. Possible DLL-loading-order/timing issue?

    if (!d_pimpl->d_ogreRoot)
        CEGUI_THROW(RendererException("The Ogre::Root object has not been "
            "created. You must initialise Ogre first!"));

    if (!d_pimpl->d_ogreRoot->isInitialised())
        CEGUI_THROW(RendererException("Ogre has not been initialised. You must "
            "initialise Ogre first!"));
}


I wonder if for some reason the 'struct OgreRenderer_impl' struct init is happening when 'CEGUIOgreRenderer-0.dll' is loaded (rather than when the first d_pimpl struct instance is directly malloc'ed), and in a release build that could be happening before 'Ogre_Main.dll' has been fully instantiated, resulting in the unexpected (timing dependant) NULL pointer.


Should I submit this modification via a pull request?

Any feedback appreciated.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Strange release-only issue.

Postby Ident » Thu Jun 12, 2014 11:19

Are you 100% sure you linked the correct libraries for release?

I havent had the issue btw. Do you get the issue also in the SampleBrowser?
CrazyEddie: "I don't like GUIs"

User avatar
Nickenstein79
Quite a regular
Quite a regular
Posts: 93
Joined: Thu May 09, 2013 06:19

Re: Strange release-only issue.

Postby Nickenstein79 » Thu Jun 12, 2014 19:40

Ident wrote:Are you 100% sure you linked the correct libraries for release?


I thought I was. But obviously I wasn't, as I've just rebuilt everything without that modification and the release build is fine.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Strange release-only issue.

Postby Ident » Thu Jun 12, 2014 21:33

Nickenstein79 wrote:
Ident wrote:Are you 100% sure you linked the correct libraries for release?


I thought I was. But obviously I wasn't, as I've just rebuilt everything without that modification and the release build is fine.

those precognition classes finally paid off. also please post in the right forum the next time (general help)
CrazyEddie: "I don't like GUIs"


Return to “Help”

Who is online

Users browsing this forum: No registered users and 24 guests