Closed Bug 113359 Opened 23 years ago Closed 23 years ago

MLK: Memory leak of 421 bytes from 9 blocks allocated in nsMsgDatabase::RowCellColumnToAddressCollationKey

Categories

(MailNews Core :: Database, defect)

x86
Windows 2000
defect
Not set
major

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: stephend, Assigned: naving)

Details

(Keywords: memory-leak)

Attachments

(4 files)

Build ID: Latest trunk, Windows 2000 using Purify.

While verifying bug 112783, I came across this:

Steps to Reproduce:

Sorry, this is all the information I have so far...

1.  My Inbox was sorted by Sender, Ascending.
2.  Had 3 visible new messages (1 near the top of the 3 pane, the other 2 near 
the bottom of the visible area).
3.  I had to find a particular message (for bug 112783) and so scrolled down to 
about the middle of my Inbox.
4.  Clicked on the message (I _bet_ this step isn't important, but you never 
know).

I'll attach screenshots of where the message in step #4 is in relation to the 
new/unread messages.

    [W] MLK: Memory leak of 421 bytes from 9 blocks allocated in PR_Malloc
        Distribution of leaked blocks
        Allocation location
        malloc         [msvcrt.DLL]
        PR_Malloc      [prmem.c:50]
        nsMsgDatabase::RowCellColumnToAddressCollationKey(nsIMdbRow *,UINT,BYTE 
* *,UINT *) [nsMsgDatabase.cpp:2813]
            }
            if (NS_SUCCEEDED(ret))
            {
     =>         ret = CreateCollationKey(NS_ConvertUTF8toUCS2(name).get(), 
result, len);
            }
        
            return ret;
        nsMsgHdr::GetAuthorCollationKey(BYTE * *,UINT *) [nsMsgHdr.cpp:642]
        
        
        NS_IMETHODIMP nsMsgHdr::GetAuthorCollationKey(PRUint8 **resultAuthor, 
PRUint32 *len)
     => {
          return m_mdb->RowCellColumnToAddressCollationKey(GetMDBRow(), m_mdb-
>m_senderColumnToken, resultAuthor, len);
        }
        
        nsMsgDBView::GetInsertIndex(nsIMsgDBHdr *) [nsMsgDBView.obj:3169]
        nsMsgDBView::AddHdr(nsIMsgDBHdr *) [nsMsgDBView.obj:3255]
        nsMsgThreadedDBView::OnNewHeader(UINT,UINT,int) 
[nsMsgThreadedDBView.cpp:536]
            // We used to check if this was the first header in the thread, but 
that's
            // a bit harder in the unreadOnly view. But we'll catch it below.
            if (! (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay))// || 
msgHdr->GetMessageKey() == m_messageDB->GetKeyOfFirstMsgInThread(msgHdr-
>GetMessageKey()))
     =>       rv = AddHdr(msgHdr);
            else    // need to find the thread we added this to so we can 
change the hasnew flag
              // added message to existing thread, but not to view
            {        // Fix flags on thread header.
        nsMsgDBView::OnKeyAdded(UINT,UINT,int,nsIDBChangeListener *) 
[nsMsgDBView.obj:3568]
        nsMsgDatabase::AddNewHdrToDB(nsIMsgDBHdr *,int) [nsMsgDatabase.cpp:2674]
                    nsMsgKey threadParent;
        
                    newHdr->GetThreadParent(&threadParent);
     =>             NotifyKeyAddedAll(key, threadParent, flags, NULL);
                }
            }
            NS_ASSERTION(NS_SUCCEEDED(err), "error creating thread");
        nsImapMailFolder::NormalEndHeaderParseStream(nsIImapProtocol *) 
[nsImapMailFolder.cpp:2555]
            }
            // here we need to tweak flags from uid state..
            if (mDatabase && (!m_msgMovedByFilter || ShowDeletedMessages()))
     =>       mDatabase->AddNewHdrToDB(newMsgHdr, PR_TRUE);
            m_msgParser->Clear(); // clear out parser, because it holds onto a 
msg hdr.
            // I don't think we want to do this - it does bad things like set 
the size incorrectly.
        //    m_msgParser->FinishHeader();
        XPTC_InvokeByIndex [xptcinvoke.cpp:152]
                mov     eax,methodIndex
                shl     eax,2               // *= 4
                add     edx,eax
     =>         call    [edx]               // stdcall, i.e. callee cleans up 
stack.
            }
        }
        #pragma warning(default : 4035) // restore default
        EventHandler   [nsProxyEvent.cpp:514]
                nsresult rv = XPTC_InvokeByIndex( proxyObject->GetRealObject(),
                                                  info->GetMethodIndex(),
                                                  info->GetParameterCount(),
     =>                                           info->GetParameterList());
                info->SetResult(rv);
            }
            else
        md_EventReceiverProc [plevent.c:1071]
            {
                PREventQueue *queue = (PREventQueue *)lParam;
                queue->removeMsg = PR_FALSE;
     =>         PL_ProcessPendingEvents(queue);
                queue->removeMsg = PR_TRUE;
        #ifdef XP_OS2
                return MRFROMLONG(TRUE);
        ScrollDC       [user32.dll]
        ScrollDC       [user32.dll]
        DispatchMessageA [user32.dll]
        DispatchMessageA [USER32.DLL]
        nsAppShell::Run(void) [nsAppShell.cpp:121]
        //      if (!nsToolkit::gAIMMMsgPumpOwner || 
(nsToolkit::gAIMMMsgPumpOwner->OnTranslateMessage(&msg) != S_OK))
        //#endif
                TranslateMessage(&msg);
     =>         ::DispatchMessage(&msg);
                if (mDispatchListener)
                  mDispatchListener->AfterDispatch();
              }
    nsAppShellService::Run(void) [nsAppShellService.cpp:301]
        
        NS_IMETHODIMP
        nsAppShellService::Run(void)
     => {
          return mAppShell->Run();
        }
        
    main1          [nsAppRunner.cpp:1269]
        
          // Start main event loop
          NS_TIMELINE_ENTER("appShell->Run");
     =>   rv = appShell->Run();
          NS_TIMELINE_LEAVE("appShell->Run");
          NS_ASSERTION(NS_SUCCEEDED(rv), "failed to run appshell");
Keywords: mlk, nsbeta1
QA Contact: esther → stephend
Attached patch proposed fixSplinter Review
free the collation keys after use.
david, need review. 
Assignee: bienvenu → naving
Comment on attachment 60275 [details] [diff] [review]
proposed fix

r=bienvenu.
Attachment #60275 - Flags: review+
Stephen, the way to reproduce this leak (and for Navin to test his fix), is to
sort the folder by sender, then get new mail in the folder. The leak was when we
were doing an insertion sort by sender on new mail inserted into a folder.
Comment on attachment 60275 [details] [diff] [review]
proposed fix

r=suresh
fixed
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Verified FIXED with the current trunk build running under Purify / Windows 2000.
Status: RESOLVED → VERIFIED
Product: MailNews → Core
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: