Crash inside CEGUI::System::destroy()

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

Ripiz
Just popping in
Just popping in
Posts: 17
Joined: Sat Oct 01, 2011 16:53

Crash inside CEGUI::System::destroy()

Postby Ripiz » Thu Oct 06, 2011 17:00

Hello again,

I use Visual Studio 11 and DirectX 11 API with DXUT. I've added CEGUI::System::destroy() inside OnDeviceDestroy() callback, however it causes my program to crash. To be exact, crash happens on line 85 in CEGUIWindowRendererModule.cpp, std::vector throws "vector iterators incompatible" error. d_registry vector is empty. I'm unsure what other information to provide, let me know what you need.

Log: http://dl.dropbox.com/u/2637453/CEGUI/C ... 0-2011.log

Tytanis
Just popping in
Just popping in
Posts: 3
Joined: Wed Oct 05, 2011 15:33

Re: Crash inside CEGUI::System::destroy()

Postby Tytanis » Thu Oct 06, 2011 20:39

On your destroy call, do this:

Code: Select all

CEGUI::System::getSingleton().destroy();
delete myRenderer;




myRenderer should be the renderer you declared in your header file along with a reset:

Code: Select all

protected:
CEGUI::Renderer* myRenderer;

Ripiz
Just popping in
Just popping in
Posts: 17
Joined: Sat Oct 01, 2011 16:53

Re: Crash inside CEGUI::System::destroy()

Postby Ripiz » Sat Oct 08, 2011 08:31

Problem didn't go away; same line, same problem.

Code: Select all

   CEGUI::Renderer *renderer = CEGUI::System::getSingleton().getRenderer();
   CEGUI::System::getSingleton().destroy();
   delete renderer;


Anymore ideas? :(

Or it's VS11 fault again?

Edit:
It cannot be VS11 fault if really. I compiled CEGUI library and Samples with VS11 and they work correctly.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Crash inside CEGUI::System::destroy()

Postby Kulik » Sat Oct 08, 2011 10:15

http://www.cegui.org.uk/docs/current/cl ... e03dd57111

You should destroy with renderer if you are bootstrapping with renderer.

Ripiz
Just popping in
Just popping in
Posts: 17
Joined: Sat Oct 01, 2011 16:53

Re: Crash inside CEGUI::System::destroy()

Postby Ripiz » Sat Oct 08, 2011 11:24

Still same problem.

Code: Select all

   CEGUI::Direct3D11Renderer *renderer = (CEGUI::Direct3D11Renderer*)CEGUI::System::getSingleton().getRenderer();
   renderer->destroySystem();



Providing my code just in case my initialization is wrong:

Code: Select all

HRESULT CALLBACK OnSwapChainResized(ID3D11Device *pd3dDevice, IDXGISwapChain *pSwapChain, const DXGI_SURFACE_DESC *pBackBufferSurfaceDesc, void *pUserContext) {
    float fAspectRatio = pBackBufferSurfaceDesc->Width / (float)pBackBufferSurfaceDesc->Height;
   camera.SetProjParams(D3DX_PI * 0.25f, fAspectRatio, 0.1, 10000);

   static CEGUI::Direct3D11Renderer *renderer = 0;
   if(!renderer) {
      renderer = &CEGUI::Direct3D11Renderer::bootstrapSystem(pDevice, pDeviceContext);

      CEGUI::DefaultResourceProvider* rp = (CEGUI::DefaultResourceProvider*)(CEGUI::System::getSingleton().getResourceProvider());
      rp->setResourceGroupDirectory("schemes", "datafiles/schemes/");
      rp->setResourceGroupDirectory("imagesets", "datafiles/imagesets/");
      rp->setResourceGroupDirectory("fonts", "datafiles/fonts/");
      rp->setResourceGroupDirectory("looknfeels", "datafiles/looknfeel/");
      rp->setResourceGroupDirectory("layouts", "datafiles/layouts/");
   
      CEGUI::Scheme::setDefaultResourceGroup("schemes");
      CEGUI::Imageset::setDefaultResourceGroup("imagesets");
      CEGUI::Font::setDefaultResourceGroup("fonts");
      CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
      CEGUI::WindowManager::setDefaultResourceGroup("layouts");

      CEGUI::XMLParser* parser = CEGUI::System::getSingleton().getXMLParser();
      if(parser->isPropertyPresent("SchemaDefaultResourceGroup"))
         parser->setProperty("SchemaDefaultResourceGroup", "schemas");

      CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
   
      using namespace CEGUI;
      SchemeManager::getSingleton().create("TaharezLook.scheme");
      System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
      WindowManager& winMgr = WindowManager::getSingleton();
      DefaultWindow* root = (DefaultWindow*)winMgr.createWindow("DefaultWindow", "Root");
      System::getSingleton().setGUISheet(root);
      FrameWindow* wnd = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "Demo Window");
      root->addChildWindow(wnd);
      wnd->setPosition(UVector2(cegui_reldim(0.25f), cegui_reldim( 0.25f)));
      wnd->setSize(UVector2(cegui_reldim(0.5f), cegui_reldim( 0.5f)));
      wnd->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
      wnd->setMinSize(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.1f)));
      wnd->setText("Hello World!");
   }

    return S_OK;
}

void CALLBACK OnFrameMove(double fTime, float fElapsedTime, void *pUserContext) {
   camera.FrameMove(fElapsedTime);
   model.OnFrameMove(fElapsedTime);

   CEGUI::System::getSingleton().injectTimePulse(fElapsedTime);
}

void CALLBACK OnFrameRender(ID3D11Device *pd3dDevice, ID3D11DeviceContext *pd3dImmediateContext, double fTime, float fElapsedTime, void *pUserContext) {
   float ClearColor[4] = {0.2, 0.2, 0.7, 0};
   ID3D11RenderTargetView *pRTV = DXUTGetD3D11RenderTargetView();
   pDeviceContext->ClearRenderTargetView(pRTV, ClearColor);

   // Clear the depth stencil
   ID3D11DepthStencilView *pDSV = DXUTGetD3D11DepthStencilView();
   pDeviceContext->ClearDepthStencilView(pDSV, D3D11_CLEAR_DEPTH, 1, 0);

   pDeviceContext->OMSetRenderTargets(1, &pRTV, pDSV);

   CEGUI::System::getSingleton().renderGUI();
}

void CALLBACK OnDeviceDestroy(void *pUserContext) {
   CEGUI::Direct3D11Renderer *renderer = (CEGUI::Direct3D11Renderer*)CEGUI::System::getSingleton().getRenderer();
   renderer->destroySystem();
}

LRESULT CALLBACK MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool *pbNoFurtherProcessing, void *pUserContext) {
   camera.HandleMessages(hWnd, uMsg, wParam, lParam);

   if(uMsg == WM_MOUSEMOVE)
      CEGUI::System::getSingleton().injectMousePosition((float)LOWORD(lParam), (float)HIWORD(lParam));
   return 0;
}


Log: http://dl.dropbox.com/u/2637453/CEGUI/C ... 0-2011.log

Edit:
This happens only if I create scheme, without scheme there's no errors. I'm thinking about trying to build in VS10 ...

Edit2:
Just tried VS10; recompiled CEGUI using VS10, compiled my code using VS10, ran it, closed program - same error.

Ripiz
Just popping in
Just popping in
Posts: 17
Joined: Sat Oct 01, 2011 16:53

Re: Crash inside CEGUI::System::destroy()

Postby Ripiz » Mon Oct 10, 2011 17:52

Sorry for double post.

CEGUI initialization is taken from samples, window code is taken from First Window sample too, therefore I cannot imagine where could be the problem (unless I'm complete retard and missed something tens of times)

I attached demo code (link in the bottom), and steps which I followed to reproduce this error, maybe I simply don't provide enough information, I don't know. Hopefully someone will be able to help me now :(

Anyways... Here's what I did and managed to reproduce the error:
1. Downloaded attached demo;
2. Downloaded CEGUI 0.7.5 ( http://prdownloads.sourceforge.net/cray ... p?download );
3. Downloaded dependencies for VS10 ( http://prdownloads.sourceforge.net/cray ... p?download );
4. Extracted CEGUI into demo's solution folder;
5. Extracted dependencies into CEGUI folder;
6. Edited CEGUI settings ( .\CEGUI-0.7.5\projects\premake\config.lua ), I made following edits:
----1) OPENGL_RENDERER = false,
----2) DIRECT3D9_RENDERER = false,
----3) DIRECT3D11_RENDERER = true,
----4) LUA_SCRIPT_MODULE = false;
7. Ran build_vs2008.bat;
8. Opened CEGUI.sln using VS10 and converted solution;
9. Choose Debug_Static build, and build solution;
10. It finally compiled. Now I open demo solution and compile Debug build (if previous steps were followed all includes and libraries will be included/linked successfully (Debug build only));
11. Copied datafiles folder from CEGUI into Demo project folder;
12. Pressed "Debug > Start Without Debugging" in Visual Studio, when program started pressed ESC to quit it and got same error (vector iterators incompatible).

Link: http://dl.dropbox.com/u/2637453/CEGUI/Demo.zip
Last edited by Ripiz on Thu Oct 13, 2011 12:55, edited 1 time in total.

MarkR
Quite a regular
Quite a regular
Posts: 64
Joined: Thu Jul 15, 2010 06:55

Re: Crash inside CEGUI::System::destroy()

Postby MarkR » Tue Oct 11, 2011 05:32

The problem sounds as if the interface of std::vector changed between msvc10 and msvc11.
I'm sure you triple-checked to link against the wrong lib, so I'd think it has something to with the dependencies.
You really should recompile all the dependencies manually.

Ripiz
Just popping in
Just popping in
Posts: 17
Joined: Sat Oct 01, 2011 16:53

Re: Crash inside CEGUI::System::destroy()

Postby Ripiz » Tue Oct 11, 2011 06:50

As I said, I used VS10 to build these. CEGUI Samples don't have any problems either, even if I use VS11. VS10 debugger points into VS10 vector file, not VS11, so I assume it links against correct one too.

Ripiz
Just popping in
Just popping in
Posts: 17
Joined: Sat Oct 01, 2011 16:53

Re: Crash inside CEGUI::System::destroy()

Postby Ripiz » Wed Oct 12, 2011 05:31

Sorry for double post again.

Just tried to compile on laptop, which never had VS11, and I get same error. It's definitely something wrong with my code but I have no idea what's exactly.

Tytanis
Just popping in
Just popping in
Posts: 3
Joined: Wed Oct 05, 2011 15:33

Re: Crash inside CEGUI::System::destroy()

Postby Tytanis » Wed Oct 12, 2011 15:50

You should be resetting your CEGUI before destroying it!

i.e.

Code: Select all


void CALLBACK OnDeviceDestroy(void *pUserContext) {
ResetGUI();
CEGUI::Direct3D11Renderer *renderer = (CEGUI::Direct3D11Renderer*)CEGUI::System::getSingleton().getRenderer();
   renderer->destroySystem();
}


// Define YourLayoutContainer with layout (YourLayoutContainer yourlayout;)
void Whatever::ResetGUI() {
   Whatever::YourLayoutContainer::iterator itr;
   for(itr = yourlayout.begin(); itr != yourlayout.end(); itr++) {
      itr->second->destroy();
   }
}


}

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Crash inside CEGUI::System::destroy()

Postby Kulik » Wed Oct 12, 2011 17:22

Tytanis wrote:You should be resetting your CEGUI before destroying it!


What? You don't have to iterate over windows and destroy each one of them, it is good practice but it's not necessary. The window manager will take care of that for you upon destruction anyways.

Ripiz
Just popping in
Just popping in
Posts: 17
Joined: Sat Oct 01, 2011 16:53

Re: Crash inside CEGUI::System::destroy()

Postby Ripiz » Wed Oct 12, 2011 19:07

Kulik wrote:
Tytanis wrote:You should be resetting your CEGUI before destroying it!


What? You don't have to iterate over windows and destroy each one of them, it is good practice but it's not necessary. The window manager will take care of that for you upon destruction anyways.


Well problem isn't about window. It's about destruction of scheme; if I don't create window it still throws error, however if I don't load scheme it's all fine.
Maybe I need to initialize CEGUI inside object or something? I think that's the only significant difference between my implementation and samples.

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

Re: Crash inside CEGUI::System::destroy()

Postby CrazyEddie » Thu Oct 13, 2011 10:56

I just want to add that mentioning the line and source file within CEGUI where an issue occurs is about as useful as a chocolate teapot. Context is everything. Any issue where you get exceptions, assertions, 'crashes' or anything else unexpected, the only way of seeing at least some of the relevant context is by providing - at least - a debug callstack (i.e one which include symbols) from the point where the issue occurs.

This said, it does not mean that after seeing this people will instantly know what the issue is, but it provides 1000x more diagnostic information than everything else posted in this thread so far.

CE.

Ripiz
Just popping in
Just popping in
Posts: 17
Joined: Sat Oct 01, 2011 16:53

Re: Crash inside CEGUI::System::destroy()

Postby Ripiz » Thu Oct 13, 2011 12:54

CrazyEddie, I understand that.
Few posts ago ( viewtopic.php?f=10&t=5868#p27814 ) I have posted steps I've done to compile CEGUI, also I've posted link to code, which has same issue.
No one told me if they are able to reproduce the problem (or not able to), therefore I assumed it's reproducible. (also I personally was able to reproduce it on two different computers, so it's supposed to work for everyone)

If it'll appear not reproducible then I'll post callstack, however if you'll be able to create same issue, then there's no need to even show callstack, as mine will simply have different pointer values.

Thank you for reply.

P.S. I used VS10 for the demo.

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

Re: Crash inside CEGUI::System::destroy()

Postby CrazyEddie » Fri Oct 14, 2011 07:39

Ripiz wrote:...I've posted link to code, which has same issue.
No one told me if they are able to reproduce the problem (or not able to), therefore I assumed it's reproducible.

The reason that nobody has responded to this (one way or the other) is that nobody is likely to take your code and try to compile it and test for this issue - and the reason for this is that nobody really cares about your issues ;)

Sure, if someone can come up with an answer based on their experiences and the information posted, they will. But to actually take time out to compile and test some random code on a forum? Extremely long odds. (For info, I most definitely will not do that, except in cases where it's 99% likely a CEGUI issue, and I've been unable to reproduce it any other way. Of course, I also do tricks in return for money :mrgreen:).

CE.


Return to “Help”

Who is online

Users browsing this forum: Google [Bot] and 6 guests