Closed Bug 303516 Opened 19 years ago Closed 6 years ago

###!!! ASSERTION: You can't dereference a NULL nsCOMPtr with operator->().: 'mRawPtr != 0', file r:\mozilla\dbg-i686-pc-cygwin\dist\include\xpcom\nsCOMPtr.h, line 849 [@ nsChromeProtocolHandler::NewChannel]

Categories

(Core :: XUL, defect, P5)

x86
Windows XP
defect

Tracking

()

RESOLVED WONTFIX

People

(Reporter: timeless, Assigned: neil)

References

Details

(Keywords: assertion, crash)

Crash Data

0[3d47f0]: ###!!! ASSERTION: You can't dereference a NULL nsCOMPtr with 
operator->().: 'mRawPtr != 0', file r:\mozilla\dbg-i686-pc-
cygwin\dist\include\xpcom\nsCOMPtr.h, line 849
0[3d47f0]: ###!!! Break: at file r:\mozilla\dbg-i686-pc-
cygwin\dist\include\xpcom\nsCOMPtr.h, line 849

NS_IMETHODIMP
nsChromeProtocolHandler::NewChannel(nsIURI* aURI,
                                    nsIChannel* *aResult)
{
    NS_ENSURE_ARG_POINTER(aURI);
    NS_PRECONDITION(aResult, "Null out param");
    
#ifdef DEBUG
    // Check that the uri we got is already canonified
    nsresult debug_rv;
    nsCOMPtr<nsIChromeRegistry> debugReg(do_GetService
(NS_CHROMEREGISTRY_CONTRACTID, &debug_rv));
    if (NS_SUCCEEDED(debug_rv)) {
        nsCOMPtr<nsIURI> debugClone;
        debug_rv = aURI->Clone(getter_AddRefs(debugClone));
        if (NS_SUCCEEDED(debug_rv)) {
            debug_rv = nsChromeRegistry::Canonify(debugClone);
            if (NS_SUCCEEDED(debug_rv)) {
                PRBool same;
                debug_rv = aURI->Equals(debugClone, &same);
                if (NS_SUCCEEDED(debug_rv)) {
                    NS_ASSERTION(same, "Non-canonified chrome uri passed to 
nsChromeProtocolHandler::NewChannel!");
                }
            }
                
        }
    }
#endif

    nsresult rv;
    nsCOMPtr<nsIChannel> result;

#ifdef MOZ_XUL
    // Check the prototype cache to see if we've already got the
    // document in the cache.
    nsCOMPtr<nsIXULPrototypeCache> cache =
             do_GetService(kXULPrototypeCacheCID, &rv);
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsIXULPrototypeDocument> proto;
    cache->GetPrototype(aURI, getter_AddRefs(proto));

    // Same comment as nsXULDocument::StartDocumentLoad and
    // nsXULDocument::ResumeWalk
    // - Ben Goodger
    //
    // We don't abort on failure here because there are too many valid
    // cases that can return failure, and the null-ness of |proto| is enough
    // to trigger the fail-safe parse-from-disk solution. Example failure cases
    // (for reference) include:
    //
    // NS_ERROR_NOT_AVAILABLE: the URI cannot be found in the FastLoad cache, 
    //                         parse from disk
    // other: the FastLoad cache file, XUL.mfl, could not be found, probably
    //        due to being accessed before a profile has been selected (e.g.
    //        loading chrome for the profile manager itself). This must be 
    //        parsed from disk. 

    if (proto) {
        // ...in which case, we'll create a dummy stream that'll just
        // load the thing.
        rv = nsCachedChromeChannel::Create(aURI, getter_AddRefs(result));
        if (NS_FAILED(rv)) return rv;
    }
    else
#endif
        {
        // Miss. Resolve the chrome URL using the registry and do a
        // normal necko load.
        //nsXPIDLCString oldSpec;
        //aURI->GetSpec(getter_Copies(oldSpec));
        //printf("*************************** %s\n", (const char*)oldSpec);

        nsCOMPtr<nsIChromeRegistry> reg = gChromeRegistry;
        if (!reg) {
            reg = do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv);
            if (NS_FAILED(rv)) return rv;
        }

        nsCOMPtr<nsIURI> chromeURI;
        rv = reg->ConvertChromeURL(aURI, getter_AddRefs(chromeURI));
        if (NS_FAILED(rv)) return rv;

        nsCOMPtr<nsIIOService> ioServ (do_GetIOService());
        if (!ioServ) return NS_ERROR_FAILURE;

        rv = ioServ->NewChannelFromURI(chromeURI, getter_AddRefs(result));
        if (NS_FAILED(rv)) return rv;

        // XXX Will be removed someday when we handle remote chrome.
        nsCOMPtr<nsIFileChannel> fileChan;
        nsCOMPtr<nsIJARChannel> jarChan;
        fileChan = do_QueryInterface(result);
        if (!fileChan)
            jarChan = do_QueryInterface(result);
        if (!fileChan && !jarChan) {
            NS_WARNING("Remote chrome not allowed! Only file:, resource:, and 
jar: are valid.\n");
            result = nsnull;
            return NS_ERROR_FAILURE;
        }

        // Make sure that the channel remembers where it was
        // originally loaded from.
        rv = result->SetOriginalURI(aURI);
        if (NS_FAILED(rv)) return rv;

        // Get a system principal for content files and set the owner
        // property of the result
        nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
        nsCAutoString path;
        rv = url->GetPath(path);

0:000> dv
            url = class nsCOMPtr<nsIURL>
           path = class nsCAutoString
      chromeURI = class nsCOMPtr<nsIURI>
            reg = class nsCOMPtr<nsIChromeRegistry>
       fileChan = class nsCOMPtr<nsIFileChannel>
         ioServ = class nsCOMPtr<nsIIOService>
   fastLoadServ = class nsCOMPtr<nsIFastLoadService>
        jarChan = class nsCOMPtr<nsIJARChannel>
           this = 0x02619848
           aURI = 0x02619548
        aResult = 0x0012ee1c
         result = class nsCOMPtr<nsIChannel>
             rv = 0
          cache = class nsCOMPtr<nsIXULPrototypeCache>
       debugReg = class nsCOMPtr<nsIChromeRegistry>
          proto = class nsCOMPtr<nsIXULPrototypeDocument>
       debug_rv = 0
0:000> dt -b necko!nsSimpleURI 0x02619548
   +0x000 __VFN_table : 0x00e52030 
   +0x004 __VFN_table : 0x00e5201c 
   +0x008 __VFN_table : 0x00e51ff0 
   +0x00c mRefCnt          : 
      +0x000 mValue           : 2
   +0x010 _mOwningThread   : nsAutoOwningThread
      +0x000 mThread          : 0x003d47f0 
   +0x014 fOuter           : 0x02619560 
   +0x018 fAggregated      : nsSimpleURI::Internal
      +0x000 __VFN_table : 0x00e520ac 
   +0x01c mScheme          : nsCString
      +0x000 mVTable          : 0x00356620 
      +0x004 mData            : 0x026195b8  "chrome"
      +0x008 mLength          : 6
      +0x00c mFlags           : 5
   +0x02c mPath            : nsCString
      +0x000 mVTable          : 0x00356620 
      +0x004 mData            : 
0x026195f8  "//navigator/locale/navigator.properties"
      +0x008 mLength          : 0x27
      +0x00c mFlags           : 5

 # 
00 ntdll!DbgBreakPoint (FPO: [0,0,0])
01 xpcom_core!nsDebugImpl::Break(char * aFile = 0x02836e54 "r:\mozilla\dbg-i686-
pc-cygwin\dist\include\xpcom\nsCOMPtr.h", int aLine = 0x351)+0x7e (FPO: [Non-
Fpo]) (CONV: stdcall) [r:\mozilla\xpcom\base\nsdebugimpl.cpp @ 350]
02 xpcom_core!nsDebugImpl::Assertion(char * aStr = 0x02836e08 "You can't 
dereference a NULL nsCOMPtr with operator->().", char * aExpr = 
0x02836e44 "mRawPtr != 0", char * aFile = 0x02836e54 "r:\mozilla\dbg-i686-pc-
cygwin\dist\include\xpcom\nsCOMPtr.h", int aLine = 0x351)+0x29e (FPO: [Non-
Fpo]) (CONV: stdcall) [r:\mozilla\xpcom\base\nsdebugimpl.cpp @ 266]
03 xpcom_core!nsDebug::Assertion(char * aStr = 0x02836e08 "You can't 
dereference a NULL nsCOMPtr with operator->().", char * aExpr = 
0x02836e44 "mRawPtr != 0", char * aFile = 0x02836e54 "r:\mozilla\dbg-i686-pc-
cygwin\dist\include\xpcom\nsCOMPtr.h", int aLine = 0x351)+0x4d (FPO: [Non-Fpo]) 
(CONV: cdecl) [r:\mozilla\dbg-i686-pc-cygwin\xpcom\build\nsdebug.cpp @ 109]
04 chrome!nsCOMPtr<nsIURL>::operator->(void)+0x29 (FPO: [Non-Fpo]) (CONV: 
thiscall) [r:\mozilla\dbg-i686-pc-cygwin\dist\include\xpcom\nscomptr.h @ 849]
05 chrome!nsChromeProtocolHandler::NewChannel(class nsIURI * aURI = 0x02619548, 
class nsIChannel ** aResult = 0x0012ee1c)+0x683 (FPO: [Non-Fpo]) (CONV: 
stdcall) [r:\mozilla\rdf\chrome\src\nschromeprotocolhandler.cpp @ 717]
06 necko!nsIOService::NewChannelFromURI(class nsIURI * aURI = 0x02619548, class 
nsIChannel ** result = 0x0012ee1c)+0x472 (FPO: [Non-Fpo]) (CONV: stdcall) 
[r:\mozilla\netwerk\base\src\nsioservice.cpp @ 493]
07 i18n!NS_NewChannel(class nsIChannel ** result = 0x0012ee90, class nsIURI * 
uri = 0x02619548, class nsIIOService * ioService = 0x00ae9778, class 
nsILoadGroup * loadGroup = 0x00000000, class nsIInterfaceRequestor * callbacks 
= 0x00000000, unsigned int loadFlags = 0)+0x3f (FPO: [Non-Fpo]) (CONV: cdecl) 
[r:\mozilla\dbg-i686-pc-cygwin\dist\include\necko\nsnetutil.h @ 170]
08 i18n!nsStringBundle::LoadProperties(void)+0x102 (FPO: [Non-Fpo]) (CONV: 
thiscall) [r:\mozilla\intl\strres\src\nsstringbundle.cpp @ 127]
09 i18n!nsStringBundle::GetStringFromName(unsigned short * aName = 
0x0012efe4 "general.useragent.locale", unsigned short ** aResult = 0x0012f2a0)
+0x69 (FPO: [Non-Fpo]) (CONV: stdcall) 
[r:\mozilla\intl\strres\src\nsstringbundle.cpp @ 279]
0a xppref32!nsPrefBranch::GetDefaultFromPropertiesFile(char * aPrefName = 
0x00e7b5f8 "general.useragent.locale", unsigned short ** return_buf = 
0x0012f2a0)+0x1d3 (FPO: [Non-Fpo]) (CONV: thiscall) 
[r:\mozilla\modules\libpref\src\nsprefbranch.cpp @ 817]
0b xppref32!nsPrefBranch::GetComplexValue(char * aPrefName = 
0x00e7b5f8 "general.useragent.locale", struct nsID * aType = 0x00e6873c, void 
** _retval = 0x0012f66c)+0x112 (FPO: [Non-Fpo]) (CONV: stdcall) 
[r:\mozilla\modules\libpref\src\nsprefbranch.cpp @ 253]
0c xppref32!nsPrefService::GetComplexValue(char * aPrefName = 
0x00e7b5f8 "general.useragent.locale", struct nsID * aType = 0x00e6873c, void 
** aValue = 0x0012f66c)+0x2a (FPO: [Non-Fpo]) (CONV: stdcall) 
[r:\mozilla\modules\libpref\src\nsprefservice.h @ 61]
0d necko!nsHttpHandler::PrefsChanged(class nsIPrefBranch * prefs = 0x00ac8fc0, 
char * pref = 0x00000000 "")+0x6fa (FPO: [Non-Fpo]) (CONV: thiscall) 
[r:\mozilla\netwerk\protocol\http\src\nshttphandler.cpp @ 840]
0e necko!nsHttpHandler::Init(void)+0x230 (FPO: [Non-Fpo]) (CONV: thiscall) 
[r:\mozilla\netwerk\protocol\http\src\nshttphandler.cpp @ 229]
0f necko!nsHttpHandlerConstructor(class nsISupports * aOuter = 0x00000000, 
struct nsID * aIID = 0x00e52fd8, void ** aResult = 0x0012f898)+0x7e (FPO: [Non-
Fpo]) (CONV: stdcall) [r:\mozilla\netwerk\build\nsnetmodule.cpp @ 203]
10 xpcom_core!nsGenericFactory::CreateInstance(class nsISupports * aOuter = 
0x00000000, struct nsID * aIID = 0x00e52fd8, void ** aResult = 0x0012f898)+0x24 
(FPO: [Non-Fpo]) (CONV: stdcall) [r:\mozilla\dbg-i686-pc-
cygwin\xpcom\build\nsgenericfactory.cpp @ 79]
11 xpcom_core!nsComponentManagerImpl::CreateInstanceByContractID(char * 
aContractID = 0x0012f924 "@mozilla.org/network/protocol;1?name=http", class 
nsISupports * aDelegate = 0x00000000, struct nsID * aIID = 0x00e52fd8, void ** 
aResult = 0x0012f898)+0x1ad (FPO: [Non-Fpo]) (CONV: stdcall) 
[r:\mozilla\xpcom\components\nscomponentmanager.cpp @ 1989]
12 xpcom_core!nsComponentManagerImpl::GetServiceByContractID(char * aContractID 
= 0x0012f924 "@mozilla.org/network/protocol;1?name=http", struct nsID * aIID = 
0x00e52fd8, void ** result = 0x0012fc20)+0x18a (FPO: [Non-Fpo]) (CONV: stdcall) 
[r:\mozilla\xpcom\components\nscomponentmanager.cpp @ 2416]
13 xpcom_core!CallGetService(char * aContractID = 
0x0012f924 "@mozilla.org/network/protocol;1?name=http", struct nsID * aIID = 
0x00e52fd8, void ** aResult = 0x0012fc20)+0x49 (FPO: [Non-Fpo]) (CONV: cdecl) 
[r:\mozilla\dbg-i686-pc-cygwin\xpcom\build\nscomponentmanagerutils.cpp @ 95]
14 necko!CallGetService<nsIProtocolHandler>(char * aContractID = 
0x0012f924 "@mozilla.org/network/protocol;1?name=http", class 
nsIProtocolHandler ** aDestination = 0x0012fc20)+0x5f (FPO: [Non-Fpo]) (CONV: 
cdecl) [r:\mozilla\dbg-i686-pc-
cygwin\dist\include\xpcom\nsservicemanagerutils.h @ 130]
15 necko!nsIOService::GetProtocolHandler(char * scheme = 0x0012fbdc "http", 
class nsIProtocolHandler ** result = 0x0012fc20)+0x16a (FPO: [Non-Fpo]) (CONV: 
stdcall) [r:\mozilla\netwerk\base\src\nsioservice.cpp @ 328]
16 docshell!nsDefaultURIFixup::CreateFixupURI(class nsACString_internal * 
aStringURI = 0x0012fccc, unsigned int aFixupFlags = 1, class nsIURI ** aURI = 
0x0012fdd4)+0x541 (FPO: [Non-Fpo]) (CONV: stdcall) 
[r:\mozilla\docshell\base\nsdefaulturifixup.cpp @ 249]
17 docshell!nsDocShell::LoadURI(unsigned short * aURI = 
0x0012fe40 "http://www.mozilla.org/projects/minimo", unsigned int aLoadFlags = 
0, class nsIURI * aReferringURI = 0x00000000, class nsIInputStream * 
aPostStream = 0x00000000, class nsIInputStream * aHeaderStream = 0x00000000)
+0x156 (FPO: [Non-Fpo]) (CONV: stdcall) 
[r:\mozilla\docshell\base\nsdocshell.cpp @ 2803]
18 webbrwsr!nsWebBrowser::LoadURI(unsigned short * aURI = 
0x0012fe40 "http://www.mozilla.org/projects/minimo", unsigned int aLoadFlags = 
0, class nsIURI * aReferringURI = 0x00000000, class nsIInputStream * 
aPostDataStream = 0x00000000, class nsIInputStream * aExtraHeaderStream = 
0x00000000)+0x64 (FPO: [Non-Fpo]) (CONV: stdcall) 
[r:\mozilla\embedding\browser\webbrowser\nswebbrowser.cpp @ 660]
19 winEmbed!OpenWebPage(char * url = 
0x00413578 "http://www.mozilla.org/projects/minimo")+0xf9 (FPO: [Non-Fpo]) 
(CONV: cdecl) [r:\mozilla\embedding\tests\winembed\winembed.cpp @ 248]
1a winEmbed!main(int argc = 1, char ** argv = 0x003d7a88)+0x173 (FPO: [Non-
Fpo]) (CONV: cdecl) [r:\mozilla\embedding\tests\winembed\winembed.cpp @ 181]
1b winEmbed!mainCRTStartup(void)+0x12c (FPO: [Non-Fpo]) (CONV: cdecl) 
[f:\vs70builds\3077\vc\crtbld\crt\src\crtexe.c @ 398]
1c kernel32!BaseProcessStart+0x23 (FPO: [Non-Fpo])
nsChromeProtocolHandler::NewURI only creates standard URLs, so who created the
simple URI that got passed to nsChromeProtocolHandler::NewChannel?
Looking at the backtrace, I think nsStringBundle::LoadProperties().
(In reply to comment #2)
> Looking at the backtrace, I think nsStringBundle::LoadProperties().
Except that nsStringBundle::LoadProperties calls NS_NewURI which calls
nsIOService::NewURI which calls nsChromeProtocolHandler::NewURI ...
Depends on: 303583
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P5
Please look at #267593, which is probably duplicate.
Still, shouldn't there be a check in nsChromeProtocolHandler::NewChannel to return some meaningful error code if the URI can't be QI'ed to nsIURL? I just spent an hour trying to understand why it was crashing...
Crash Signature: [@ nsChromeProtocolHandler::NewChannel]
Closing because no crash reported since 12 weeks.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.