MLK in StringBundleTest.cpp

RESOLVED WORKSFORME

Status

()

Core
Internationalization
RESOLVED WORKSFORME
13 years ago
10 years ago

People

(Reporter: David Gardiner, Assigned: David Gardiner)

Tracking

({mlk})

Trunk
x86
All
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

13 years ago
Running StringBundleTest.exe in Purify gives the following memory leaks:

    [W] MLK: Memory leak of 24 bytes from 1 block allocated in PR_Malloc [nspr4.dll]
        Distribution of leaked blocks
            24 bytes from 1 block of 24 bytes (0x0349cf60)
        Allocation location
        malloc         [dbgheap.c:138]
        _CRTIMP void * __cdecl malloc (
                size_t nSize
                )
     => {
                void *res = _nh_malloc_dbg(nSize, _newmode, _NORMAL_BLOCK, NULL, 0);
        
                RTCCALLBACK(_RTC_Allocate_hook, (res, nSize, 0));
        PR_Malloc      [prmem.c:477]
        #if defined (WIN16)
            return PR_MD_malloc( (size_t) size);
        #else
     =>     return malloc(size);
        #endif
        }
        
        NS_Alloc_P     [nsmemoryimpl.cpp:367]
        {
            NS_ASSERTION(size, "NS_Alloc of size 0");
        
     =>     void* result = MALLOC1(size);
            if (! result) {
                // Request an asynchronous flush
               
sGlobalMemory.FlushMemory(NS_LITERAL_STRING("alloc-failure").get(), PR_FALSE);
        nsMemory::Alloc(UINT) [nsmemory.h:68]
        {
        public:
            static NS_HIDDEN_(void*) Alloc(size_t size)
     =>         { return NS_Alloc(size); }
        
            static NS_HIDDEN_(void*) Realloc(void* ptr, PRSize size)
                { return NS_Realloc(ptr, size); }
        ?AllocateStringCopy@VnsAString@@G@@YAPAGABVnsAString@@PAG@Z
[nsreadableutils.cpp:310]
        ToCharT*
        AllocateStringCopy( const FromStringT& aSource, ToCharT* )
          {
     =>     return NS_STATIC_CAST(ToCharT*, nsMemory::Alloc((aSource.Length()+1)
* sizeof(ToCharT)));
          }
        
        
        ToNewUnicode(nsAString const&) [nsreadableutils.cpp:369]
          {
            // no conversion needed, just allocate a buffer of the correct
length and copy into it
        
     =>     PRUnichar* result = AllocateStringCopy(aSource, (PRUnichar*)0);
        
            nsAString::const_iterator fromBegin, fromEnd;
            PRUnichar* toBegin = result;
        nsStringBundle::GetStringFromID(int,WORD * *) [nsstringbundle.cpp:258]
          rv = GetStringFromID(aID, tmpstr);
          NS_ENSURE_SUCCESS(rv, rv);
        
     =>   *aResult = ToNewUnicode(tmpstr);
          NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
        
          return NS_OK;
        main           [stringbundletest.cpp:139]
          char *value = nsnull;
        
          // 123
     =>   ret = bundle->GetStringFromID(123, &ptrv);
          if (NS_FAILED(ret)) {
            printf("cannot get string from ID 123, ret=%d\n", ret);
            return 1;
        mainCRTStartup [crtexe.c:398]
                    mainret = wmain(argc, argv, envp);
        #else  /* WPRFLAG */
                    __initenv = envp;
     =>             mainret = main(argc, argv, envp);
        #endif  /* WPRFLAG */
        
        #endif  /* _WINMAIN_ */
    [W] MLK: Memory leak of 12 bytes from 1 block allocated in PR_Malloc [nspr4.dll]
        Distribution of leaked blocks
            12 bytes from 1 block of 12 bytes (0x03518f58)
        Allocation location
        malloc         [dbgheap.c:138]
        _CRTIMP void * __cdecl malloc (
                size_t nSize
                )
     => {
                void *res = _nh_malloc_dbg(nSize, _newmode, _NORMAL_BLOCK, NULL, 0);
        
                RTCCALLBACK(_RTC_Allocate_hook, (res, nSize, 0));
        PR_Malloc      [prmem.c:477]
        #if defined (WIN16)
            return PR_MD_malloc( (size_t) size);
        #else
     =>     return malloc(size);
        #endif
        }
        
        NS_Alloc_P     [nsmemoryimpl.cpp:367]
        {
            NS_ASSERTION(size, "NS_Alloc of size 0");
        
     =>     void* result = MALLOC1(size);
            if (! result) {
                // Request an asynchronous flush
               
sGlobalMemory.FlushMemory(NS_LITERAL_STRING("alloc-failure").get(), PR_FALSE);
        nsMemory::Alloc(UINT) [nsmemory.h:68]
        {
        public:
            static NS_HIDDEN_(void*) Alloc(size_t size)
     =>         { return NS_Alloc(size); }
        
            static NS_HIDDEN_(void*) Realloc(void* ptr, PRSize size)
                { return NS_Realloc(ptr, size); }
        ?AllocateStringCopy@VnsAString@@D@@YAPADABVnsAString@@PAD@Z
[nsreadableutils.cpp:310]
        ToCharT*
        AllocateStringCopy( const FromStringT& aSource, ToCharT* )
          {
     =>     return NS_STATIC_CAST(ToCharT*, nsMemory::Alloc((aSource.Length()+1)
* sizeof(ToCharT)));
          }
        
        
        ToNewCString(nsAString const&) [nsreadableutils.cpp:318]
        char*
        ToNewCString( const nsAString& aSource )
          {
     =>     char* result = AllocateStringCopy(aSource, (char*)0);
        
            nsAString::const_iterator fromBegin, fromEnd;
            LossyConvertEncoding<PRUnichar, char> converter(result);
        main           [stringbundletest.cpp:145]
            return 1;
          }
          v = ptrv;
     =>   value = ToNewCString(v);
          printf("123=\"%s\"\n", value);
        
          nsMemory::Free(ptrv);
        mainCRTStartup [crtexe.c:398]
                    mainret = wmain(argc, argv, envp);
        #else  /* WPRFLAG */
                    __initenv = envp;
     =>             mainret = main(argc, argv, envp);
        #endif  /* WPRFLAG */
        
        #endif  /* _WINMAIN_ */
    [W] MLK: Memory leak of 10 bytes from 1 block allocated in PR_Malloc [nspr4.dll]
        Distribution of leaked blocks
            10 bytes from 1 block of 10 bytes (0x033622f8)
        Allocation location
        malloc         [dbgheap.c:138]
        _CRTIMP void * __cdecl malloc (
                size_t nSize
                )
     => {
                void *res = _nh_malloc_dbg(nSize, _newmode, _NORMAL_BLOCK, NULL, 0);
        
                RTCCALLBACK(_RTC_Allocate_hook, (res, nSize, 0));
        PR_Malloc      [prmem.c:477]
        #if defined (WIN16)
            return PR_MD_malloc( (size_t) size);
        #else
     =>     return malloc(size);
        #endif
        }
        
        NS_Alloc_P     [nsmemoryimpl.cpp:367]
        {
            NS_ASSERTION(size, "NS_Alloc of size 0");
        
     =>     void* result = MALLOC1(size);
            if (! result) {
                // Request an asynchronous flush
               
sGlobalMemory.FlushMemory(NS_LITERAL_STRING("alloc-failure").get(), PR_FALSE);
        nsMemory::Alloc(UINT) [nsmemory.h:68]
        {
        public:
            static NS_HIDDEN_(void*) Alloc(size_t size)
     =>         { return NS_Alloc(size); }
        
            static NS_HIDDEN_(void*) Realloc(void* ptr, PRSize size)
                { return NS_Realloc(ptr, size); }
        ?AllocateStringCopy@VnsAString@@G@@YAPAGABVnsAString@@PAG@Z
[nsreadableutils.cpp:310]
        ToCharT*
        AllocateStringCopy( const FromStringT& aSource, ToCharT* )
          {
     =>     return NS_STATIC_CAST(ToCharT*, nsMemory::Alloc((aSource.Length()+1)
* sizeof(ToCharT)));
          }
        
        
        ToNewUnicode(nsAString const&) [nsreadableutils.cpp:369]
          {
            // no conversion needed, just allocate a buffer of the correct
length and copy into it
        
     =>     PRUnichar* result = AllocateStringCopy(aSource, (PRUnichar*)0);
        
            nsAString::const_iterator fromBegin, fromEnd;
            PRUnichar* toBegin = result;
        nsStringBundle::GetStringFromName(WORD const*,WORD * *)
[nsstringbundle.cpp:281]
          rv = GetStringFromName(nsDependentString(aName), tmpstr);
          NS_ENSURE_SUCCESS(rv, rv);
        
     =>   *aResult = ToNewUnicode(tmpstr);
          NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
        
          return NS_OK;
        main           [stringbundletest.cpp:152]
          nsString strfile;
          strfile.AssignLiteral("file");
          const PRUnichar *ptrFile = strfile.get();
     =>   ret = bundle->GetStringFromName(ptrFile, &ptrv);
          if (NS_FAILED(ret)) {
            printf("cannot get string from name\n");
            return 1;
        mainCRTStartup [crtexe.c:398]
                    mainret = wmain(argc, argv, envp);
        #else  /* WPRFLAG */
                    __initenv = envp;
     =>             mainret = main(argc, argv, envp);
        #endif  /* WPRFLAG */
        
        #endif  /* _WINMAIN_ */
    [W] MLK: Memory leak of 5 bytes from 1 block allocated in PR_Malloc [nspr4.dll]
        Distribution of leaked blocks
             5 bytes from 1 block of 5 bytes (0x034ed0a8)
        Allocation location
        malloc         [dbgheap.c:138]
        _CRTIMP void * __cdecl malloc (
                size_t nSize
                )
     => {
                void *res = _nh_malloc_dbg(nSize, _newmode, _NORMAL_BLOCK, NULL, 0);
        
                RTCCALLBACK(_RTC_Allocate_hook, (res, nSize, 0));
        PR_Malloc      [prmem.c:477]
        #if defined (WIN16)
            return PR_MD_malloc( (size_t) size);
        #else
     =>     return malloc(size);
        #endif
        }
        
    NS_Alloc_P     [nsmemoryimpl.cpp:367]
        {
            NS_ASSERTION(size, "NS_Alloc of size 0");
        
     =>     void* result = MALLOC1(size);
            if (! result) {
                // Request an asynchronous flush
               
sGlobalMemory.FlushMemory(NS_LITERAL_STRING("alloc-failure").get(), PR_FALSE);
    nsMemory::Alloc(UINT) [nsmemory.h:68]
        {
        public:
            static NS_HIDDEN_(void*) Alloc(size_t size)
     =>         { return NS_Alloc(size); }
        
            static NS_HIDDEN_(void*) Realloc(void* ptr, PRSize size)
                { return NS_Realloc(ptr, size); }
    ?AllocateStringCopy@VnsAString@@D@@YAPADABVnsAString@@PAD@Z
[nsreadableutils.cpp:310]
        ToCharT*
        AllocateStringCopy( const FromStringT& aSource, ToCharT* )
          {
     =>     return NS_STATIC_CAST(ToCharT*, nsMemory::Alloc((aSource.Length()+1)
* sizeof(ToCharT)));
          }
        
        
    ToNewCString(nsAString const&) [nsreadableutils.cpp:318]
        char*
        ToNewCString( const nsAString& aSource )
          {
     =>     char* result = AllocateStringCopy(aSource, (char*)0);
        
            nsAString::const_iterator fromBegin, fromEnd;
            LossyConvertEncoding<PRUnichar, char> converter(result);
    main           [stringbundletest.cpp:158]
          ret = bundle->GetStringFromName(ptrFile, &ptrv);
          if (NS_FAILED(ret)) {
            printf("cannot get string from name\n");
     =>     return 1;
          }
          v = ptrv;
          value = ToNewCString(v);
    mainCRTStartup [crtexe.c:398]
                    mainret = wmain(argc, argv, envp);
        #else  /* WPRFLAG */
                    __initenv = envp;
     =>             mainret = main(argc, argv, envp);
        #endif  /* WPRFLAG */
        
        #endif  /* _WINMAIN_ */
(Assignee)

Comment 1

13 years ago
Created attachment 173822 [details] [diff] [review]
Fix memory leaks
Assignee: smontagu → david.gardiner
Status: NEW → ASSIGNED
Attachment #173822 - Flags: review?(blizzard)
Attachment #173822 - Flags: review?(blizzard) → review+
(Assignee)

Comment 2

13 years ago
Comment on attachment 173822 [details] [diff] [review]
Fix memory leaks

Are you able to sr this too, or should I ask someone else?

-david
Attachment #173822 - Flags: superreview?(blizzard)
Attachment #173822 - Flags: superreview?(blizzard) → superreview+

Comment 3

10 years ago
StringBundleTest.cpp is no more.

http://bonsai.mozilla.org/cvsquery.cgi?treeid=default&module=all&branch=HEAD&branchtype=match&dir=&file=&filetype=match&who=&whotype=match&sortby=Date&hours=2&date=explicit&mindate=2007-05-09+20%3A58&maxdate=2007-05-09+22%3A58&cvsroot=%2Fcvsroot

Sorry this never got checked in.  We have a weird convention that patch contributors without CVS access are supposed to find someone with CVS access to check in patches for them, and other patches get forgotten.
Status: ASSIGNED → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.