About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
[Solved] Unhandled exception during shutdown after latest update
Author Message
miro@3dea Offline
Member

Post: #1
[Solved] Unhandled exception during shutdown after latest update
Hello!

after latest update and correction of sources to fit the newest API our application is running well until shutdown where it fails after the Shut() function is called by EE.
Exception says:
Code:
Unhandled exception at 0x000000013FA8B913 in 3Dea.exe: 0xC0000005: Access violation reading location 0x000007FEF6B806C0
and call stack looks like this:
Code:
    3Dea.exe!EE::ShutWindow(void)
    3Dea.exe!EE::Application::del(void)
    3Dea.exe!WinMain()
    3Dea.exe!__tmainCRTStartup() Line 238    C
    kernel32.dll!00000000773f652d()    Unknown
    ntdll.dll!000000007788c521()    Unknown

any hints?
tnx&cu..
(This post was last modified: 02-27-2013 04:15 PM by miro@3dea.)
01-29-2013 04:06 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Unhandled exception during shutdown after latest update
Hi,

Does this happen with any of the EE SDK provided tutorials or only your own application?

Can you let me know your system config? (What Windows OS version)

Can you execute this code in InitPre:
Code:
ITaskbarList2 *TaskbarList=NULL;
   const GUID IID_ITaskbarList3={ 0xea1afb91,0x9e28,0x4b86,{0x90,0xe9,0x9e,0x9f,0x8a,0x5e,0xef,0xaf}};
   CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_ALL, IID_ITaskbarList3, (Ptr*)&TaskbarList);

  // this is called in ShutWindow (where crash happens on your computer)
   if(TaskbarList){TaskbarList->Release(); TaskbarList=NULL;}
For me it does not crash

Perhaps you manually call 'CoUninitialize' ?
01-29-2013 06:56 PM
Find all posts by this user Quote this message in a reply
miro@3dea Offline
Member

Post: #3
RE: Unhandled exception during shutdown after latest update
Hi Chief,
yes, I call CoUninitialize manually, and it is very, VERY important to do it manually for our app. Actually CoInitializeEx and CoUninitialize are called multiple times..

p.s. Win7 is in use, and no crashes in tutorial: start.cpp
(This post was last modified: 01-30-2013 09:31 AM by miro@3dea.)
01-30-2013 09:26 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Unhandled exception during shutdown after latest update
The engine already calls CoInitialize(NULL) at start of the app (before InitPre)
and CoUninitialize(); (after Shut)
so you don't need to call those functions manually
perhaps you have a bug and you don't check for RPC_E_CHANGED_MODE return in CoInitialize for which you should not call CoUninitialize
Summary: the crash happens because of incorrect pair match of calls to CoInitialize/CoUninitialize
01-30-2013 12:03 PM
Find all posts by this user Quote this message in a reply
miro@3dea Offline
Member

Post: #5
RE: Unhandled exception during shutdown after latest update
First of all of course we are checking pairing Init/Uninit and COM interface return values wink as I said those calls (and other COM calls) are very important for our game.
We have next situation: very first call in InitPre() is ::CoUninitialize(); and easiest solution for this problem would be to call ::CoInitialize(nullptr); as last statement in Shut().
If we do it this way, can you please tell me is there any EE interface that is COM dependent and if there is which are those?
Other solution would be for you to Init/Uninit COM only when you are using COM objects in the engine. Are you willing to implement it this way? That would very very helpful!!
Tnx&br
01-30-2013 12:39 PM
Find all posts by this user Quote this message in a reply
miro@3dea Offline
Member

Post: #6
RE: Unhandled exception during shutdown after latest update
so... I've tried to init com in Shut() as:
Code:
HRESULT hr = ::CoInitialize(NULL);
hr value is 0 - S_OK, which means com initialized as expected but same exception is thrown in a same place.
To summarize:
1. in InitPre() I call ::CoUninitialize() as very first statement
2. during the game there are multiple calls to CoInitializeEx(...) - multithreaded and single threaded, and each call is paired with CoUninitialize..
- this behavior up worked flawlessly until new January 2013. update.
While trying to avoid unhandled exception I've tried to add next step:
3. in Shut() I call ::CoInitialize(NULL)
but unfortunately exception is still there same as without step 3.
Please help, I'm stuck :-(
01-30-2013 05:26 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: Unhandled exception during shutdown after latest update
Perhaps you can't call CoUninitialize while the engine still uses some interfaces.

The engine does this:
CoInitialize(NULL);
init interfaces
InitPre();
..your codes
Shut();
close interfaces
CoUninitialize();

I really don't see the point of constant calling CoInitialize/CoUninitialize, when the engine already does this once at app start and end.
All you need to do is don't call CoInitialize/CoUninitialize at all, and just rely on the 1 pair of CoInitialize/CoUninitialize that engine already calls, will that work?
01-30-2013 05:40 PM
Find all posts by this user Quote this message in a reply
miro@3dea Offline
Member

Post: #8
RE: Unhandled exception during shutdown after latest update
Yes, we can get it work with relaying on CoInitialize called by the engine, but it is a workaround in our case, so please be so kind to read the next request:
we have a windows shell extension as a part of our game we use extensively. That extension was meant to be used not as single apartment threaded only, but also as multithreaded apartment when necessary (this is the reason for constant calling CoInitialize/CoUninitialize). Because of that it would be great if the game itself can have control over com initialization.
Is it possible to make it happen?
01-31-2013 01:03 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #9
RE: Unhandled exception during shutdown after latest update
Can you please let me know if that's the desired initialization of the COM library for you?
Code:
CoInitializeEx(NULL, COINIT_MULTITHREADED)

I could make a function that you would call in InitPre/Init and it would change com initialization to above codes, and reinitialize the interfaces that the engine uses.
02-03-2013 12:17 PM
Find all posts by this user Quote this message in a reply
miro@3dea Offline
Member

Post: #10
RE: Unhandled exception during shutdown after latest update
If you could allow initialization with bitmask that would be great. Something like:
Code:
EE::ComInit(Int bitmask);
So we could use it like:
Code:
EE::ComInit(COINIT_APARTMENTTHREADED | COINIT_SPEED_OVER_MEMORY | COINIT_DISABLE_OLE1DDE);
...
EE::ComInit(COINIT_MULTITHREADED | COINIT_SPEED_OVER_MEMORY);
...
Thanks a lot!!
02-06-2013 10:16 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #11
RE: Unhandled exception during shutdown after latest update
Ok, that's reasonable, I'll add this to the next SDK
02-06-2013 02:35 PM
Find all posts by this user Quote this message in a reply
miro@3dea Offline
Member

Post: #12
RE: Unhandled exception during shutdown after latest update
Perfect! Thanks chief!!
02-06-2013 02:42 PM
Find all posts by this user Quote this message in a reply
Post Reply