FatalExecutionEngineError MessagePump() window close

Kwang1imsa

31-03-2011 03:25:43

Here is my code:
while (SFMLWin.IsOpened() && !OGREWin.IsClosed)
{
SFMLWin.CurrentView.Move(camera);
SFMLWin.DispatchEvents();
WindowEventUtilities.MessagePump();
if (globalPressed)
{
OnKeyHold();
}
MainDraw();
}

When I close the window, I get
FatalExecutionEngineError was detected

The runtime has encountered a fatal error. The address of the error was at 0x61696c9e, on thread 0x3018. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.


I'm guessing this has something to do with closing the window. Any ideas?

CodeKrash

01-04-2011 01:59:17

are you using any worker threads that modify a mogre object?

Kwang1imsa

01-04-2011 02:57:04

Nope. That's essentially all of the code.

CodeKrash

02-04-2011 00:53:54

yeah, after closing the window, the control that mogre paints to is disposed. Another guess would be that mogre is trying to render to a disposed control after form closure. I have received that same error upon shutdown too but I can't remember what it was.

Kwang1imsa

06-04-2011 16:19:10

Well, there it is.

Kwang1imsa

12-07-2011 06:42:57

Bump:

So I know I posted this a while ago, but I have not found a solution (more specifically, I thought I found a solution but I didn't).

When this problem resurfaced again, I even forgot that I posted this and I ended up posting another topic. :/

But this is my main application loop:

while (SFMLWin.IsOpened() && !OGREWin.IsClosed)
{
try
{
if (fpsClock.Milliseconds > 0)
fps = 1000 / fpsClock.Milliseconds;
fpsClock.Reset();
SFMLWin.DispatchEvents();
SFMLWin.GetFrameTime();
inputKeyboard.Capture();
inputMouse.Capture();
OnCollision();
OnKeyHold();
MainDraw();
WindowEventUtilities.MessagePump();
}
catch
{
break;
}
}
SFMLWin.Dispose();
OGREWin.Dispose();


I am still getting the "FatalExecutionError" code when I close OGREWin at WindowEventUtilities.MessagePump();. The try/catch statement doesn't catch anything, and I can't implement any if statements around WindowEventUtilities.MessagePump() to fix the situation. This is a very urgent issue now, and I am really stumped on what to do.

Kwang1imsa

13-07-2011 22:42:26

Update:

I've posted this in StackOverflowe and got a response.

The native code is corrupting the garbage collected heap. Possibly due to a bad pinvoke declaration, but you'll have a heck of a time finding it. The place where it crashes is not the place where the damage is done. It is not a catchable exception in .NET 4, it is too severe a heart attack. Cut your losses if you can't get help from the authors. – Hans Passant

From this response, this means that it could me an error in MOGRE. Please advise.

smiley80

13-07-2011 23:36:12

Can you upload the project somewhere?

Kwang1imsa

14-07-2011 03:55:59

After stripping things out until something worked, I've discovered this:

SFMLWin = new SFML.Graphics.RenderWindow(hwnd);

The error only occurs when I have passed OGRE's window handle to SFML's Renderwindow, meaning when OGRE's window closes, WindowEventUtilities.MessagePump(); must have done something to the closed SFML window.

Is there any way to unbind SFML's renderwindow from OGREWin's handle?

I will also post something on the SFML Forums.