I have created an XPCOM component to wrap a COM component. The XPCOM
component creates instance on the COM component and calls some methods
then exits. The XPCOM component runs great, but when I close the app
it deadlocks. If I remove the COM calls from my XPCOM component, the
app exits properly. I have run the XUL/XPCOM from both xulrunner and
my own exe that links to the xul runtime and I get the same effect.
I debugged into my XUL exe and found that the execution hangs after
ExitProcess(). I looked for ExitProcess on MSDN and found the
following:
"Remarks
Exiting a process causes the following:
1. All of the object handles opened by the process are closed.
2. All of the threads in the process, except the calling thread,
terminate their execution. The entry-point functions of all loaded
dynamic-link libraries (DLLs) are called with DLL_PROCESS_DETACH. After
all attached DLLs have executed any process termination code, this
function terminates the current process, including the calling thread.
3. The state of the process object becomes signaled, satisfying any
threads that had been waiting for the process to terminate.
4. The states of all threads of the process become signaled, satisfying
any threads that had been waiting for the threads to terminate.
5. The termination status of the process changes from STILL_ACTIVE to
the exit value of the process.
If one of the terminated threads in the process holds a lock and the
DLL detach code in one of the loaded DLLs attempts to acquire the same
lock, then calling ExitProcess results in a deadlock. "
>From this I assume that COM and xul or XPCOM are holding the same lock.
I am not sure why either they would have the same lock. This is just
an assumption.
Fearing that it might be the COM component, I created a simple COM
component and just called CoCreateInstance(CLSID, NULL,
CLSCTX_INPROC_SERVER) on it from a method in the XPCOM component. The
same problem occurred, so I concluded the problem is not in my COM
code.
I have included the stack trace from when I break into the hung
application. I hope this provides some insight.
[EMAIL PROTECTED]()
[EMAIL PROTECTED]() + 0xc
[EMAIL PROTECTED]() + 0x8b
[EMAIL PROTECTED]() + 0x12
ole32.dll!CoWaitForMultipleHandles() + 0xfc93
ole32.dll!CoGetComCatalog() + 0x116b
ole32.dll!CoGetComCatalog() + 0x10d1
ole32.dll!CoInitializeEx() + 0x2b6
ole32.dll!CoUninitialize() + 0x52
xul.dll!MOZ_Z_compressBound() + 0x1972
[EMAIL PROTECTED]() + 0x14
[EMAIL PROTECTED]() + 0x142
[EMAIL PROTECTED]() + 0x42
kernel32.dll!7c81cab6()
msvcr71d.dll!__crtExitProcess(int status=0) Line 464 C
msvcr71d.dll!doexit(int code=0, int quick=0, int retcaller=0) Line
414 + 0x9 C
msvcr71d.dll!exit(int code=0) Line 303 + 0xd C
MyApp.exe!WinMainCRTStartup() Line 406 C
[EMAIL PROTECTED]() + 0x23
So my question is, is there a known issue running COM from XPCOM? If
so, is there a work around?
OS: Windows XP SP2
Compiler: Cl.exe v7.10.3077
I am building a debug version of the Mozilla libraries to see what I
can see. I will update this topic if I find more information.
_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom