I can't seem to get a handle on what is causing the problem below.
In particular, why should the AddRef in the running mozilla case belong to
nsBinaryInputStream? I have stepped through the debugger and found that
QueryInterface and Release for this same object don't refer back to
nsBinaryInputStream, but to nsServiceManagerImpl as you would expect. How can
this be?
Could someone help me out here? Is it possible I am linking my plugin
incorrectly? I am currently linking it against the xpcom.lib. Is there
something else I need to do?
Steve Katz
In article <2iFa7.16738$[EMAIL PROTECTED]>, Steven Katz says...
>
>Ok,
>
>I rebuilt mozilla with:
>set MOZ_PROFILE=1
>set MOZ_DEBUG=
>
>as recommended in the debugging FAQ
>
>Now what happens is my Registration function runs to completion, but regxpcom
>still crashes (but in a different place). Here is the stack trace:
>
>nsDll::Sync(nsDll * const 0x00836f60) line 245
>nsNativeComponentLoader::SelfRegisterDll(nsNativeComponentLoader * const
>0x00836f60, nsDll * 0x007d0030, const char * 0x00836f60, int 0x00000000) line
>519
>nsNativeComponentLoader::AutoRegisterComponent(nsNativeComponentLoader * const
>0x007c4be0, int 0x00000000, nsIFile * 0x00836fa0, int * 0x007d1f60) line 912
>AutoRegisterComponent_enumerate(nsHashKey * 0x007c4a70, void * 0x00000000, void
>* 0x0012fed8) line 2131 + 22 bytes
>_hashEnumerate(PLHashEntry * 0x007c4a50, int 0x00000000, void * 0x0012fec0) line
>194 + 19 bytes
>PL_HashTableEnumerateEntries(PLHashTable * 0x1000b0da, int (PLHashEntry *, int,
>void *)* 0x007c4ba8, void * 0x1000b0e6 _hashEnumerate(PLHashEntry *, int, void
>*)) line 413 + 7 bytes
>nsHashtable::Enumerate(nsHashtable * const 0x00836f60, int (nsHashKey *, void *,
>void *)* 0x100286f8 AutoRegisterComponent_enumerate(nsHashKey *, void *, void
>*), void * 0x0012fed8) line 371 + 29 bytes
>nsComponentManagerImpl::AutoRegisterComponent(nsComponentManagerImpl * const
>0x007c3900, int 0x00000000, nsIFile * 0x00835090) line 2172
>nsComponentManager::AutoRegisterComponent(int 0x00000000, nsIFile * 0x00835090)
>line 211
>Register(const char * 0x007c02b5) line 56 + 11 bytes
>ProcessArgs(int 0x00000001, char * * 0x007c02a0) line 148 + 5 bytes
>main(int 0x00000002, char * * 0x007c02a0) line 182 + 13 bytes
>REGXPCOM! mainCRTStartup + 227 bytes
>KERNEL32! 77f1ba06()
>
>
>If I then try and run mozilla, it too crashes. Here is it's stack trace:
>
>nsBinaryInputStream::AddRef(nsBinaryInputStream * const 0x80000000) line 50 + 4
>bytes
>CJavaPluginFactory::CJavaPluginFactory(CJavaPluginFactory * const 0x00813e70,
>CJavaPluginApp * 0x01a523f0 class CJavaPluginApp g_App, nsISupports *
>0x00813e70) line 138
>CJavaPluginFactory::Create(nsISupports * 0x00000000, const nsID & {...}, void *
>* 0x0012fb1c) line 624 + 38 bytes
>nsGenericFactory::CreateInstance(nsGenericFactory * const 0x01759d30,
>nsISupports * 0x00000000, const nsID & {...}, void * * 0x0012fb1c) line 59
>nsComponentManagerImpl::CreateInstance(nsComponentManagerImpl * const
>0x00813750, const nsID & {...}, nsISupports * 0x00000000, const nsID & {...},
>void * * 0x01759d30) line 1231 + 16 bytes
>nsComponentManager::CreateInstance(const nsID & {...}, nsISupports * 0x00000000,
>const nsID & {...}, void * * 0x0012fb1c) line 82
>nsServiceManagerImpl::GetService(nsServiceManagerImpl * const 0x00000000, const
>nsID & {...}, const nsID & {...}, nsISupports * * 0x0012fb98,
>nsIShutdownListener * 0x00000000) line 344 + 17 bytes
>nsServiceManagerImpl::GetService(nsServiceManagerImpl * const 0x00813e70, const
>char * 0x019f8030 ??_C@_0DB@DPCL@?$EAmozilla?4org?1inline?9plugin?1appli@, const
>nsID & {...}, nsISupports * * 0x0012fb98, nsIShutdownListener * 0x00000000) line
>492
>nsServiceManager::GetService(const char * 0x019f8030
>??_C@_0DB@DPCL@?$EAmozilla?4org?1inline?9plugin?1appli@, const nsID & {...},
>nsISupports * * 0x0012fb98, nsIShutdownListener * 0x00000000) line 605
>nsGetServiceByContractID::operator()(const nsGetServiceByContractID * const
>0x00813e70, const nsID & {...}, void * * 0x0012fb98) line 64 + 14 bytes
>nsCOMPtr_base::assign_from_helper(nsCOMPtr_base * const 0x00813e70, const
>nsCOMPtr_helper & {...}, const nsID & {...}) line 65 + 14 bytes
>nsJVMManager::StartupJVM(nsJVMManager * const 0x00813e70) line 601 + 42 bytes
>nsJVMManager::MaybeStartupLiveConnect(nsJVMManager * const 0x00813e70) line 784
>+ 18 bytes
>nsJVMManager::StartupLiveConnect(nsJVMManager * const 0x01758648, JSRuntime *
>0x00bb4448, int & 0x00000000) line 127 + 12 bytes
>nsJSEnvironment::nsJSEnvironment(nsJSEnvironment * const 0x00813e70) line 1550 +
>12 bytes
>nsJSEnvironment::GetScriptingEnvironment() line 1468 + 19 bytes
>NS_CreateScriptContext(nsIScriptGlobalObject * 0x0174f780, nsIScriptContext * *
>0x017512ec) line 1598
>nsDOMSOFactory::NewScriptContext(nsDOMSOFactory * const 0x01747010,
>nsIScriptGlobalObject * 0x0174f780, nsIScriptContext * * 0x017512ec) line 120 +
>13 bytes
>nsDocShell::EnsureScriptEnvironment(nsDocShell * const 0x01747010) line 5879
>nsWebShell::GetInterface(nsWebShell * const 0x01751268, const nsID & {...}, void
>* * 0x0012fd64) line 286 + 16 bytes
>nsGetInterface::operator()(const nsGetInterface * const 0x00813e70, const nsID &
>{...}, void * * 0x0012fd64) line 37 + 10 bytes
>nsCOMPtr_base::assign_from_helper(nsCOMPtr_base * const 0x00813e70, const
>nsCOMPtr_helper & {...}, const nsID & {...}) line 65 + 14 bytes
>nsAppShellService::GetHiddenWindowAndJSContext(nsAppShellService * const
>0x01751240, nsIDOMWindowInternal * * 0x00000000, JSContext * * 0x0012fdc8) line
>743 + 32 bytes
>nsAppShellService::SetXPConnectSafeContext(nsAppShellService * const 0x00813e70)
>line 188
>nsAppShellService::CreateHiddenWindow(nsAppShellService * const 0x008e65a0) line
>264
>main1(int 0x00000001, char * * 0x008102c0, nsISupports * 0x008102a0) line 1273
>main(int 0x00000001, char * * 0x008102c0) line 1599 + 25 bytes
>WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00400000, char * 0x0013364f,
>HINSTANCE__ * 0x00400000) line 1617 + 21 bytes
>MOZILLA! WinMainCRTStartup + 308 bytes
>KERNEL32! 77f1ba06()
>
>
>Does anyone have any insite as to what might be happening here??
>
>
>thanks,
>
>Steve Katz
>
>PS. When I replaced the MACROS with the actual code (in the NS_RELEASE case
>described below), it [the debugger] show the crash occuring when the "delete
>this" was called on nsPluginHostImpl in gkplugin.dll.
>
>In article <Sqea7.15142$[EMAIL PROTECTED]>, Steven Katz says...
>>
>>Here is the code for my Registration and Creation Functions:
>>
>>static NS_DEFINE_CID(kJavaPluginCID,NS_JAVAPLUGIN_CID);
>>
>>static const char * mt[] = { "application/x-java-vm" };
>>static const char * fe[] = { "" };
>>static const char * md[] = { "Java(tm) Plug-in" };
>>
>>static nsModuleComponentInfo components[] =
>>{
>>{ "Java Plug-in (TM) Service",
>>NS_JAVAPLUGIN_CID,
>>NS_INLINE_PLUGIN_CONTRACTID_PREFIX NS_JVM_MIME_TYPE,
>>CJavaPluginFactory::Create,
>>CJavaPluginFactory::RegisterSelf,
>>CJavaPluginFactory::UnregisterSelf,
>>}
>>};
>>
>>NS_IMPL_NSGETMODULE("JavaPluginModule", components)
>>
>>
>>NS_METHOD CJavaPluginFactory::Create(nsISupports* outer,
>>const nsIID& aIID,
>>void* *aInstancePtr) {
>>
>>
>>nsresult rv = NS_ERROR_UNEXPECTED;
>>CJavaPluginFactory * f = NULL;
>>nsIServiceManager * sm = NULL;
>>
>>rv = nsServiceManager::GetGlobalServiceManager(&sm);
>>if(NS_FAILED(rv) || (sm == NULL)) {
>>fprintf(stderr,"Could not get Service Manager!!\n");
>>} else {
>>
>>fprintf(stderr,"In the Create function!!!!\n");
>>f = new CJavaPluginFactory(&g_App,sm);
>>
>>if(f != NULL) {
>>rv = f->QueryInterface(aIID,aInstancePtr);
>>if(NS_FAILED(rv)) {
>>rv = f->CreateInstance(outer,aIID,aInstancePtr);
>>}
>>}
>>}
>>
>>return rv;
>>}
>>
>>
>>NS_METHOD CJavaPluginFactory::RegisterSelf(nsIComponentManager *aCompMgr,
>>nsIFile *aPath,
>>const char *registryLocation,
>>const char *componentType,
>>const nsModuleComponentInfo *info) {
>>
>>nsresult rv;
>>nsIPluginManager *pm;
>>
>>int numberoftypes = sizeof(md)/sizeof(*md);
>>
>>rv =
>>nsServiceManager::GetService(kCPluginManagerCID,NS_GET_IID(nsIPluginManager),
>>NS_REINTERPRET_CAST(nsISupports**, &pm));
>>
>>if(NS_SUCCEEDED(rv)) {
>>pm->RegisterPlugin(kJavaPluginCID,
>>"Java(tm) Plug-in",
>>"Sun's Java(tm) Plug-in",
>>(const char **) mt,
>>(const char **) md,
>>(const char **) fe,
>>numberoftypes);
>>NS_RELEASE(pm);
>>}
>>
>>fprintf(stderr, "Returing from registration with %X\n",rv);
>>return rv;
>>}
>>
>>
>>WHen I sent my previous message, I had forgotten that I commented out the
>>NS_RELEASE() call in the RegisterSelf function. I have since put it back in.
>>
>>As a result the code now asserts when I register the plugin (with regxpcom) say
>>that:
>>
>>nsPluginHostImpl is not thread safe...file z:\mozilla\xpcom\base\nsDebug.cpp
>>
>>The if I hit the "Ignore" button the code crashes with the following stack
>>trace:
>>
>>nsPluginHostImpl::Release(...)
>>CJavaPluginFactory::RegisterSelf(...)
>>..
>>main(...)
>>
>>Does anyone know how to save the stack trace out of VC++, or copy it to a file
>>some how??
>>
>>If I comment out the NS_RELEASE() call, then the registration will run to
>>completion, but mozilla crashes when it comes up (as described in the previous
>>post)
>>
>>To answer you specic question it is the IMPL MACROS that are crashing.
>>
>>
>>
>>In article <[EMAIL PROTECTED]>, Rick Parrish says...
>>>
>>>Steven Katz wrote:
>>>
>>>> When I try and run mozilla however, it crashes in a QueryInterface() call to the
>>>> GlobalServiceManger. You see the old way, via NSGetFactory(), provided the
>>>> Service manager as a variable passed into the NSGetFactory() call. The new way
>>>> does not, so as a workaround (since our code expects to get this at creation
>>>> time) I locate the ServiceManager with
>>>> nsServiceManager::GetGlobalServiceManager() and pass this to the constructor as
>>>> a replacement for what we use to get from NSGetFactory().
>>>
>>>
>>>Which macros are you using or are suspect?
>>>
>>>ie. NS_IMPL_XXXX vs. NS_DECL_XXXX
>>>
>>>Also, could you post some code?
>>>
>>>-rick
>>>
>>>
>>
>>
>
>