Closed Bug 206195 Opened 21 years ago Closed 21 years ago

Memory leak of 20 bytes from 1 block allocated in nsAbLDAPDirFactory::CreateDirectory

Categories

(MailNews Core :: LDAP Integration, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED INVALID

People

(Reporter: stephend, Assigned: sspitzer)

Details

(Keywords: memory-leak)

Windows 2000 trunk under Purify (debug).

1.  Launch mozilla.exe -addressbook
2.  Click New Card.
3.  Type 'S' anywhere and click Save.
4.  Shutdown.

We leak:

    [W] MLK: Memory leak of 20 bytes from 1 block allocated in
nsAbLDAPDirFactory::CreateDirectory(nsIAbDirectoryProperties
*,nsISimpleEnumerator * *)
        Distribution of leaked blocks
        Allocation location
        new(UINT)      [new.cpp:23]
        nsAbLDAPDirFactory::CreateDirectory(nsIAbDirectoryProperties
*,nsISimpleEnumerator * *) [nsAbLDAPDirFactory.cpp:135]
            rv = directory->SetDirPrefId(prefName);
            NS_ENSURE_SUCCESS(rv, rv);
        
     =>     NS_IF_ADDREF(*aDirectories = new nsSingletonEnumerator(directory));
            return *aDirectories ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
        }
        
        nsAbBSDirectory::CreateDirectoriesFromFactory(nsIAbDirectoryProperties
*,DIR_Server *,int) [nsAbBSDirectory.cpp:129]
        
            // Create the directories
            nsCOMPtr<nsISimpleEnumerator> newDirEnumerator;
     =>     rv = dirFactory->CreateDirectory(aProperties,
getter_AddRefs(newDirEnumerator));
            NS_ENSURE_SUCCESS (rv, rv);
        
            // Enumerate through the directories adding them
        nsAbBSDirectory::GetChildNodes(nsIEnumerator * *) [nsAbBSDirectory.cpp:228]
        
                    // Create the directories
              rv = CreateDirectoriesFromFactory(properties,
     =>         server, PR_FALSE /* notify */);
                }
        
                mInitialized = PR_TRUE;
        nsAbDirectoryDataSource::GetTargets(nsIRDFResource *,nsIRDFResource
*,int,nsISimpleEnumerator * *) [nsDirectoryDataSource.cpp:241]
            {
              nsCOMPtr<nsIEnumerator> subDirectories;
        
     =>       rv = directory->GetChildNodes(getter_AddRefs(subDirectories));
              NS_ENSURE_SUCCESS(rv, rv);
              nsAdapterEnumerator* cursor =
                new nsAdapterEnumerator(subDirectories);
        CompositeAssertionEnumeratorImpl::GetEnumerator(nsIRDFDataSource
*,nsISimpleEnumerator * *) [nsCompositeDataSource.cpp:573]
                         nsISimpleEnumerator** aResult)
        {
            if (mSource) {
     =>         return aDataSource->GetTargets(mSource, mProperty, mTruthValue,
aResult);
            }
            else {
                return aDataSource->GetSources(mProperty, mTarget, mTruthValue,
aResult);
        CompositeEnumeratorImpl::HasMoreElements(int *)
[nsCompositeDataSource.cpp:239]
                    nsIRDFDataSource* datasource =
                        mCompositeDataSource->mDataSources[mNext];
        
     =>             rv = GetEnumerator(datasource, &mCurrent);
                    if (NS_FAILED(rv)) return rv;
                    if (rv == NS_RDF_NO_VALUE)
                        continue;
    nsRDFConMemberTestNode::FilterInstantiations(InstantiationSet&,void *)const
[nsRDFConMemberTestNode.cpp:389]
        
                        while (1) {
                            PRBool hasmore;
     =>                     rv = results->HasMoreElements(&hasmore);
                            if (NS_FAILED(rv)) return rv;
        
                            if (! hasmore)
    TestNode::Propagate(InstantiationSet const&,void *) [nsRuleNetwork.cpp:1041]
                   ("TestNode[%p]: Propagate() begin", this));
        
            InstantiationSet instantiations = aInstantiations;
     =>     rv = FilterInstantiations(instantiations, aClosure);
            if (NS_FAILED(rv)) return rv;
        
            if (! instantiations.Empty()) {
    TestNode::Propagate(InstantiationSet const&,void *) [nsRuleNetwork.cpp:1050]
                    PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
                           ("TestNode[%p]: Propagate() passing to child %p",
this, kid.operator->()));
        
     =>             kid->Propagate(instantiations, aClosure);
                }
            }
on first glance, everything looks okay here... maybe purify is getting confused?

i'm unable to confirm this since i can't get this code to execute. maybe your
addrbook is set up differently to mine... any ideas on how i can reproduce?

if you have 15 minutes to throw some printf's and rebuild, lemme know ;)
Index: addrbook/src/nsAbLDAPDirFactory.cpp
===================================================================
RCS file: /cvsroot/mozilla/mailnews/addrbook/src/nsAbLDAPDirFactory.cpp,v
retrieving revision 1.8
diff -u -r1.8 nsAbLDAPDirFactory.cpp
--- addrbook/src/nsAbLDAPDirFactory.cpp 5 Mar 2003 02:49:15 -0000       1.8
+++ addrbook/src/nsAbLDAPDirFactory.cpp 19 May 2003 07:05:04 -0000
@@ -69,6 +69,7 @@
 NS_IMETHODIMP nsAbLDAPDirFactory::CreateDirectory(nsIAbDirectoryProperties *aPr
operties,
     nsISimpleEnumerator **aDirectories)
 {
+         printf("\nRheet, we're here in nsAbLDAPDirFactory::CreateDirectory");
     NS_ENSURE_ARG_POINTER(aProperties);
     NS_ENSURE_ARG_POINTER(aDirectories);
Index: ds/nsEnumeratorUtils.cpp
===================================================================
RCS file: /cvsroot/mozilla/xpcom/ds/nsEnumeratorUtils.cpp,v
retrieving revision 3.11
diff -u -r3.11 nsEnumeratorUtils.cpp
--- ds/nsEnumeratorUtils.cpp    15 Mar 2003 01:04:09 -0000      3.11
+++ ds/nsEnumeratorUtils.cpp    19 May 2003 07:03:49 -0000
@@ -117,6 +117,7 @@
 nsSingletonEnumerator::~nsSingletonEnumerator()
 {
     NS_IF_RELEASE(mValue);
+    printf("\nWe're here in ~nsSingletonEnumerator, did we kill mValue? %u", PR
Uint32(mValue));
 }

 NS_IMPL_ISUPPORTS1(nsSingletonEnumerator, nsISimpleEnumerator)

Those two additions output:

Rheet, we're here in nsAbLDAPDirFactory::CreateDirectory
We're here in ~nsSingletonEnumerator, did we kill mValue? 0
We're here in ~nsSingletonEnumerator, did we kill mValue? 0
We're here in ~nsSingletonEnumerator, did we kill mValue? 0

Yet, Purify still shows this as a 'leak'.  Not sure what's going on here?
hammer showed me some printf's that show the ctor & dtor calls to
nsSingletonEnumerator are evenly matched... so my guess is purify is getting
confused somewhere.

-> invalid
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → INVALID
verified
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.