Closed Bug 106860 Opened 23 years ago Closed 23 years ago

FastLoad service (or updater) leaking

Categories

(Core :: XPCOM, defect, P3)

x86
Windows 2000
defect

Tracking

()

VERIFIED FIXED
mozilla0.9.7

People

(Reporter: stephend, Assigned: brendan)

References

Details

(Keywords: memory-leak)

Attachments

(1 file)

Trunk CVS pull @8pm (tonight), Windows 2000.

Using the autocomplete setup provided by hong@netscape.com.

Steps to Reproduce:

1.  Mozilla.exe -compose.
2.  Type dmos (it'll complete to Dan Mosedale <dmose@netscape.com>).
3.  Tab to subject.
4.  Exit.

[W] MLK: Memory leak of 2048 bytes from 1 block allocated in PL_DHashAllocTable
    Distribution of leaked blocks
    Allocation location
    malloc+0xc           [C:\WINNT\SYSTEM32\msvcrt.DLL ip=0x580013eb]
    PL_DHashAllocTable+0x2b [c:\moz_src\mozilla\xpcom\ds\pldhash.c:62 
ip=0x10058b8e]
    
    PR_IMPLEMENT(void *)
    PL_DHashAllocTable(PLDHashTable *table, PRUint32 nbytes)
 => {
        return malloc(nbytes);
    }
    
    PL_DHashTableOperate+0x248 [c:\moz_src\mozilla\xpcom\ds\pldhash.c:514 
ip=0x100596ff]
                 * falling through might claim the last free entry.
                 */
                if (!ChangeTable(table, deltaLog2) &&
 =>                 table->entryCount + table->removedCount == size - 1) {
                    METER(table->stats.addFailures++);
                    return NULL;
                }
    nsFastLoadFileUpdater::CopyReadDocumentMapEntryToUpdater(PLDHashTable 
*,PLDHashEntryHdr *,UINT,void *)+0xad 
[c:\moz_src\mozilla\xpcom\io\nsFastLoadFile.cpp:2197 ip=0x100a121e]
        nsDocumentMapWriteEntry* writeEntry =
            NS_STATIC_CAST(nsDocumentMapWriteEntry*,
                           PL_DHashTableOperate(&updater->mDocumentMap, spec,
 =>                                             PL_DHASH_ADD));
        if (!writeEntry) {
            nsMemory::Free(spec);
            return PL_DHASH_STOP;
    nsFastLoadFileUpdater::Open(nsFastLoadFileReader *)+0x3e1 
[c:\moz_src\mozilla\xpcom\io\nsFastLoadFile.cpp:2277 ip=0x100a16c5]
        // If we didn't enumerate all entries, we ran out of memory.
        n = PL_DHashTableEnumerate(&aReader->mFooter.mDocumentMap,
                                   CopyReadDocumentMapEntryToUpdater,
 =>                                this);
        if (n != aReader->mFooter.mDocumentMap.entryCount)
            return NS_ERROR_OUT_OF_MEMORY;
    
    NS_NewFastLoadFileUpdater(nsIObjectOutputStream * *,nsIOutputStream 
*,nsIObjectInputStream *)+0x15a 
[c:\moz_src\mozilla\xpcom\io\nsFastLoadFile.cpp:2339 ip=0x100a1b22]
        nsCOMPtr<nsIObjectOutputStream> stream(updater);
    
        nsresult rv = updater->Open(NS_STATIC_CAST(nsFastLoadFileReader*,
 =>                                                aReaderAsStream));
        if (NS_FAILED(rv))
            return rv;
    
    nsFastLoadService::StartMuxedDocument(nsISupports *,char const*,int)+0x29f 
[c:\moz_src\mozilla\xpcom\io\nsFastLoadService.cpp:266 ip=0x1006c0bc]
                    // NB: mInputStream must be an nsFastLoadFileReader!
                    rv = NS_NewFastLoadFileUpdater(getter_AddRefs
(mOutputStream),
                                                   output,
 =>                                                mInputStream);
                    if (NS_FAILED(rv))
                        return rv;
                }
    nsXULDocument::PrepareToLoadPrototype(nsIURI *,char const*,nsIPrincipal 
*,nsIParser * *)+0x2c0 
[c:\moz_src\mozilla\content\xul\document\src\nsXULDocument.cpp:5154 
ip=0x0561f95a]
            // from the pre-existing part of the file.
            rv = gFastLoadService->StartMuxedDocument(aURI, urlspec,
                                              
nsIFastLoadService::NS_FASTLOAD_READ |
 =>                                           
nsIFastLoadService::NS_FASTLOAD_WRITE);
            NS_ASSERTION(rv != NS_ERROR_NOT_AVAILABLE, "only reading 
FastLoad?!");
            if (NS_FAILED(rv))
                AbortFastLoads();
    nsXULDocument::PrepareToLoad(nsISupports *,char const*,nsIChannel 
*,nsILoadGroup *,nsIParser * *)+0x13f 
[c:\moz_src\mozilla\content\xul\document\src\nsXULDocument.cpp:5110 
ip=0x0561f645]
    
        nsCOMPtr<nsIPrincipal> principal = do_QueryInterface(owner);
    
 =>     return PrepareToLoadPrototype(mDocumentURL, aCommand, principal, 
aResult);
    }
    
    
    nsXULDocument::StartDocumentLoad(char const*,nsIChannel *,nsILoadGroup 
*,nsISupports *,nsIStreamListener * *,int)+0x65e 
[c:\moz_src\mozilla\content\xul\document\src\nsXULDocument.cpp:807 
ip=0x0560bf9c]
            // It's just a vanilla document load. Create a parser to deal
            // with the stream n' stuff.
            nsCOMPtr<nsIParser> parser;
 =>         rv = PrepareToLoad(aContainer, aCommand, aChannel, aLoadGroup, 
getter_AddRefs(parser));
            if (NS_FAILED(rv)) return rv;
        
                nsCOMPtr<nsIStreamListener> listener = do_QueryInterface
(parser, &rv);
    nsContentDLF::CreateRDFDocument(char const*,nsIChannel *,nsILoadGroup 
*,char const*,nsISupports *,nsISupports *,nsIStreamListener * 
*,nsIContentViewer * *)+0x16c 
[c:\moz_src\mozilla\content\build\nsContentDLF.cpp:423 ip=0x05428645]
           * An nsIStreamListener connected to the parser is returned in
           * aDocListener.
           */
     =>   rv = doc->StartDocumentLoad(aCommand, aChannel, aLoadGroup, 
aContainer, aDocListener, PR_TRUE);
          if (NS_SUCCEEDED(rv)) {
            /*
             * Bind the document to the Content Viewer...
    nsContentDLF::CreateInstance(char const*,nsIChannel *,nsILoadGroup *,char 
const*,nsISupports *,nsISupports *,nsIStreamListener * *,nsIContentViewer * *)
+0x592 [c:\moz_src\mozilla\content\build\nsContentDLF.cpp:244 ip=0x05427af3]
              return CreateRDFDocument(aCommand,
                                       aChannel, aLoadGroup,
                                       aContentType, aContainer,
     =>                                aExtraInfo, aDocListener, aDocViewer);
            }
          }
        
    nsDocShell::NewContentViewerObj(char const*,nsIRequest *,nsILoadGroup 
*,nsIStreamListener * *,nsIContentViewer * *)+0x394 
[c:\moz_src\mozilla\docshell\base\nsDocShell.cpp:3584 ip=0x05990dc5]
    nsDocShell::CreateContentViewer(char const*,nsIRequest *,nsIStreamListener 
* *)+0x149 [c:\moz_src\mozilla\docshell\base\nsDocShell.cpp:3468 ip=0x05990648]
    nsDSURIContentListener::DoContent(char const*,int,nsIRequest 
*,nsIStreamListener * *,int *)+0x235 
[c:\moz_src\mozilla\docshell\base\nsDSURIContentListener.cpp:106 ip=0x0599faea]
    nsDocumentOpenInfo::DispatchContent(nsIRequest *,nsISupports *)+0x7ba 
[c:\moz_src\mozilla\uriloader\base\nsURILoader.cpp:367 ip=0x04c7fb05]
    nsDocumentOpenInfo::OnStartRequest(nsIRequest *,nsISupports *)+0x1b7 
[c:\moz_src\mozilla\uriloader\base\nsURILoader.cpp:241 ip=0x04c7f0df]
    nsJARChannel::OnStartRequest(nsIRequest *,nsISupports *)+0x81 
[c:\moz_src\mozilla\netwerk\protocol\jar\src\nsJARChannel.cpp:583 ip=0x0487f671]
    md_EventReceiverProc+0x61 [c:\moz_src\mozilla\xpcom\threads\plevent.c:1071 
ip=0x100cc829]
    ScrollDC+0x490       [C:\WINNT\SYSTEM32\user32.dll ip=0x77e12e98]
I think this might be Brendan's, but I'm not sure.  I'm already aware that 
Purify is not always the most accurate tool.  Please correct/invalidate this 
bug as is the appropriate call.  Thanks.
Keywords: mailtrack, mlk
Anyone know how Exit (step 4) works?  Does it shut down XPCOM services properly?

/be
Exit() does not shutdown xpcom.
What kind of exit doesn't shutdown XPCOM?  After the event loop exits, we exit
main1 and main calls NS_ShutdownXPCOM.
*** Bug 106839 has been marked as a duplicate of this bug. ***
Probably cuz I suck at C++.  Or XPCOM hates me.  (I hate it back! ;-)

/be
Status: NEW → ASSIGNED
Keywords: mozilla0.9.6
Priority: -- → P3
Summary: Memory leak of 2048 bytes from 1 block allocated in PL_DHashAllocTable → FastLoad service (or updater) leaking
Target Milestone: --- → mozilla0.9.6
*** Bug 106859 has been marked as a duplicate of this bug. ***
*** Bug 107762 has been marked as a duplicate of this bug. ***
This should be fixed soon.

/be
Target Milestone: mozilla0.9.6 → mozilla0.9.7
I ran into a pretty simple reproduceable testcase:
 1. delete XUL.mfasl
 2. Start browser
 3. click X in corner of window to exit
 4. Start browser again
 5. File | Manage Bookmarks
 6. Click X in corner of bookmarks window, then navigator window.

I see a leaked nsFastLoadFileWriter (which owns an nsBufferedStream through its
mOutputStream and mBufferAccess).  It leaks for a very simple reason, the line:
    mFileIO = this;
on line 2343 of nsFastLoadFile.cpp, which creates the simplest possible type of
circular reference ownership. :-)
Comment on attachment 59065 [details] [diff] [review]
proposed fix (plus eliminate useless tell and seek around loop that [it turns out] never reads)

r/sr = bienvenu, whichever you want.
Attachment #59065 - Flags: review+
Comment on attachment 59065 [details] [diff] [review]
proposed fix (plus eliminate useless tell and seek around loop that [it turns out] never reads)

r=dbaron
Attachment #59065 - Flags: superreview+
Fix is in, thanks (esp. to dbaron for the big assist in finding what should have
been an obvious cycle!).

/be
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
*** Bug 111781 has been marked as a duplicate of this bug. ***
verified fixed with the latest win32 tip
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: