You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by "Travis Vitek (JIRA)" <ji...@apache.org> on 2007/10/12 01:44:50 UTC

[jira] Created: (STDCXX-587) purify reports memory leak from __rw_tmpbuf in 20.temp.buffer.mt

purify reports memory leak from __rw_tmpbuf in 20.temp.buffer.mt
----------------------------------------------------------------

                 Key: STDCXX-587
                 URL: https://issues.apache.org/jira/browse/STDCXX-587
             Project: C++ Standard Library
          Issue Type: Improvement
          Components: Tests
            Reporter: Travis Vitek
            Priority: Minor
             Fix For: 4.2.1


Each test thread iterates some number of times switching on a counter. If the last iteration runs one of the allocation functions, the temporary buffer will not be deallocated when the thread exits.

Purify: Searching for all memory leaks...

Memory leaked: 42 bytes (6.98%); potentially leaked: 0 bytes (0%)

MLK: 24 bytes leaked at 0x81089d0
  * This memory was allocated from:
    malloc         [rtlib.o]
    operator new(unsigned) [libstd15d.so]
    __rw::__rw_allocate(unsigned, int) [memory.cpp:53]
    __rw_tmpbuf    [tmpbuf.cpp:115]
    std::pair<long long*, int > std::get_temporary_buffer<long long, int >(int, long long*) [_rawiter.h:138]
    std::pair<long long*, int > std::get_temporary_buffer<long long>(int) [_rawiter.h:153]

MLK: 18 bytes leaked at 0x8108a38
  * This memory was allocated from:
    malloc         [rtlib.o]
    operator new(unsigned) [libstd15d.so]
    __rw::__rw_allocate(unsigned, int) [memory.cpp:53]
    __rw_tmpbuf    [tmpbuf.cpp:115]
    std::pair<short*, int > std::get_temporary_buffer<short, int >(int, short*) [_rawiter.h:138]
    std::pair<short*, int > std::get_temporary_buffer<short>(int) [_rawiter.h:153]


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (STDCXX-587) purify reports memory leak from __rw_tmpbuf in 20.temp.buffer.mt

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-587?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Travis Vitek updated STDCXX-587:
--------------------------------

    Attachment: stdcxx-587.patch

2007-10-11  Travis Vitek  <vi...@roguewave.com>

	STDCXX-587
	* 20.temp.buffer.mt.cpp (test_return_buffer): Set buffer pointer
	to 0 after deallocating.
	(thr_func): Provide default values for buffers. Deallocate buffers
	that remain allocated after thread loop.

> purify reports memory leak from __rw_tmpbuf in 20.temp.buffer.mt
> ----------------------------------------------------------------
>
>                 Key: STDCXX-587
>                 URL: https://issues.apache.org/jira/browse/STDCXX-587
>             Project: C++ Standard Library
>          Issue Type: Improvement
>          Components: Tests
>            Reporter: Travis Vitek
>            Priority: Minor
>             Fix For: 4.2.1
>
>         Attachments: stdcxx-587.patch
>
>
> Each test thread iterates some number of times switching on a counter. If the last iteration runs one of the allocation functions, the temporary buffer will not be deallocated when the thread exits.
> Purify: Searching for all memory leaks...
> Memory leaked: 42 bytes (6.98%); potentially leaked: 0 bytes (0%)
> MLK: 24 bytes leaked at 0x81089d0
>   * This memory was allocated from:
>     malloc         [rtlib.o]
>     operator new(unsigned) [libstd15d.so]
>     __rw::__rw_allocate(unsigned, int) [memory.cpp:53]
>     __rw_tmpbuf    [tmpbuf.cpp:115]
>     std::pair<long long*, int > std::get_temporary_buffer<long long, int >(int, long long*) [_rawiter.h:138]
>     std::pair<long long*, int > std::get_temporary_buffer<long long>(int) [_rawiter.h:153]
> MLK: 18 bytes leaked at 0x8108a38
>   * This memory was allocated from:
>     malloc         [rtlib.o]
>     operator new(unsigned) [libstd15d.so]
>     __rw::__rw_allocate(unsigned, int) [memory.cpp:53]
>     __rw_tmpbuf    [tmpbuf.cpp:115]
>     std::pair<short*, int > std::get_temporary_buffer<short, int >(int, short*) [_rawiter.h:138]
>     std::pair<short*, int > std::get_temporary_buffer<short>(int) [_rawiter.h:153]

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (STDCXX-587) purify reports memory leak from __rw_tmpbuf in 20.temp.buffer.mt

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-587?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Travis Vitek reassigned STDCXX-587:
-----------------------------------

    Assignee: Travis Vitek

> purify reports memory leak from __rw_tmpbuf in 20.temp.buffer.mt
> ----------------------------------------------------------------
>
>                 Key: STDCXX-587
>                 URL: https://issues.apache.org/jira/browse/STDCXX-587
>             Project: C++ Standard Library
>          Issue Type: Improvement
>          Components: Tests
>            Reporter: Travis Vitek
>            Assignee: Travis Vitek
>            Priority: Minor
>             Fix For: 4.2.1
>
>         Attachments: stdcxx-587.patch
>
>
> Each test thread iterates some number of times switching on a counter. If the last iteration runs one of the allocation functions, the temporary buffer will not be deallocated when the thread exits.
> Purify: Searching for all memory leaks...
> Memory leaked: 42 bytes (6.98%); potentially leaked: 0 bytes (0%)
> MLK: 24 bytes leaked at 0x81089d0
>   * This memory was allocated from:
>     malloc         [rtlib.o]
>     operator new(unsigned) [libstd15d.so]
>     __rw::__rw_allocate(unsigned, int) [memory.cpp:53]
>     __rw_tmpbuf    [tmpbuf.cpp:115]
>     std::pair<long long*, int > std::get_temporary_buffer<long long, int >(int, long long*) [_rawiter.h:138]
>     std::pair<long long*, int > std::get_temporary_buffer<long long>(int) [_rawiter.h:153]
> MLK: 18 bytes leaked at 0x8108a38
>   * This memory was allocated from:
>     malloc         [rtlib.o]
>     operator new(unsigned) [libstd15d.so]
>     __rw::__rw_allocate(unsigned, int) [memory.cpp:53]
>     __rw_tmpbuf    [tmpbuf.cpp:115]
>     std::pair<short*, int > std::get_temporary_buffer<short, int >(int, short*) [_rawiter.h:138]
>     std::pair<short*, int > std::get_temporary_buffer<short>(int) [_rawiter.h:153]

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (STDCXX-587) purify reports memory leak from __rw_tmpbuf in 20.temp.buffer.mt

Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-587?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12537302 ] 

Farid Zaripov commented on STDCXX-587:
--------------------------------------

Oh, You're right. I looked the test source too quickly and draw attention only on % 8 operation :)

Commited thus: http://svn.apache.org/viewvc?view=rev&revision=587873

> purify reports memory leak from __rw_tmpbuf in 20.temp.buffer.mt
> ----------------------------------------------------------------
>
>                 Key: STDCXX-587
>                 URL: https://issues.apache.org/jira/browse/STDCXX-587
>             Project: C++ Standard Library
>          Issue Type: Improvement
>          Components: Tests
>            Reporter: Travis Vitek
>            Priority: Minor
>             Fix For: 4.2.1
>
>         Attachments: stdcxx-587.patch
>
>
> Each test thread iterates some number of times switching on a counter. If the last iteration runs one of the allocation functions, the temporary buffer will not be deallocated when the thread exits.
> Purify: Searching for all memory leaks...
> Memory leaked: 42 bytes (6.98%); potentially leaked: 0 bytes (0%)
> MLK: 24 bytes leaked at 0x81089d0
>   * This memory was allocated from:
>     malloc         [rtlib.o]
>     operator new(unsigned) [libstd15d.so]
>     __rw::__rw_allocate(unsigned, int) [memory.cpp:53]
>     __rw_tmpbuf    [tmpbuf.cpp:115]
>     std::pair<long long*, int > std::get_temporary_buffer<long long, int >(int, long long*) [_rawiter.h:138]
>     std::pair<long long*, int > std::get_temporary_buffer<long long>(int) [_rawiter.h:153]
> MLK: 18 bytes leaked at 0x8108a38
>   * This memory was allocated from:
>     malloc         [rtlib.o]
>     operator new(unsigned) [libstd15d.so]
>     __rw::__rw_allocate(unsigned, int) [memory.cpp:53]
>     __rw_tmpbuf    [tmpbuf.cpp:115]
>     std::pair<short*, int > std::get_temporary_buffer<short, int >(int, short*) [_rawiter.h:138]
>     std::pair<short*, int > std::get_temporary_buffer<short>(int) [_rawiter.h:153]

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (STDCXX-587) purify reports memory leak from __rw_tmpbuf in 20.temp.buffer.mt

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-587?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12537122 ] 

Travis Vitek commented on STDCXX-587:
-------------------------------------

That option was not considered because it doesn't actually eliminate the leak. :P Consider the case where rw_opt_nloops is 1 and there are 4 threads. The switch for the last iteration for each thread will be '((rw_opt_nloops*8-1) + targs->threadno_) % 8' for each thread so we have

thread 0: 7 + 0 % 8 => 7
thread 1: 7 + 1 % 8 => 0
thread 2: 7 + 2 % 8 => 1
thread 3: 7 + 3 % 8 => 2

So on the last iteration, threads 1, 2 and 3 will allocate memory. Not good. There is that and the fact that the number of loops executed would be 8x what the user requested with the --nloops command line option.

I also considered allocating and deallocating from the same case block, but that has the disadvantage that it doesn't test multiple outstanding allocations from the same thread.



> purify reports memory leak from __rw_tmpbuf in 20.temp.buffer.mt
> ----------------------------------------------------------------
>
>                 Key: STDCXX-587
>                 URL: https://issues.apache.org/jira/browse/STDCXX-587
>             Project: C++ Standard Library
>          Issue Type: Improvement
>          Components: Tests
>            Reporter: Travis Vitek
>            Priority: Minor
>             Fix For: 4.2.1
>
>         Attachments: stdcxx-587.patch
>
>
> Each test thread iterates some number of times switching on a counter. If the last iteration runs one of the allocation functions, the temporary buffer will not be deallocated when the thread exits.
> Purify: Searching for all memory leaks...
> Memory leaked: 42 bytes (6.98%); potentially leaked: 0 bytes (0%)
> MLK: 24 bytes leaked at 0x81089d0
>   * This memory was allocated from:
>     malloc         [rtlib.o]
>     operator new(unsigned) [libstd15d.so]
>     __rw::__rw_allocate(unsigned, int) [memory.cpp:53]
>     __rw_tmpbuf    [tmpbuf.cpp:115]
>     std::pair<long long*, int > std::get_temporary_buffer<long long, int >(int, long long*) [_rawiter.h:138]
>     std::pair<long long*, int > std::get_temporary_buffer<long long>(int) [_rawiter.h:153]
> MLK: 18 bytes leaked at 0x8108a38
>   * This memory was allocated from:
>     malloc         [rtlib.o]
>     operator new(unsigned) [libstd15d.so]
>     __rw::__rw_allocate(unsigned, int) [memory.cpp:53]
>     __rw_tmpbuf    [tmpbuf.cpp:115]
>     std::pair<short*, int > std::get_temporary_buffer<short, int >(int, short*) [_rawiter.h:138]
>     std::pair<short*, int > std::get_temporary_buffer<short>(int) [_rawiter.h:153]

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (STDCXX-587) purify reports memory leak from __rw_tmpbuf in 20.temp.buffer.mt

Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-587?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Farid Zaripov closed STDCXX-587.
--------------------------------


> purify reports memory leak from __rw_tmpbuf in 20.temp.buffer.mt
> ----------------------------------------------------------------
>
>                 Key: STDCXX-587
>                 URL: https://issues.apache.org/jira/browse/STDCXX-587
>             Project: C++ Standard Library
>          Issue Type: Improvement
>          Components: Tests
>    Affects Versions: 4.2.0
>            Reporter: Travis Vitek
>            Assignee: Travis Vitek
>            Priority: Minor
>             Fix For: 4.2.1
>
>         Attachments: stdcxx-587.patch
>
>
> Each test thread iterates some number of times switching on a counter. If the last iteration runs one of the allocation functions, the temporary buffer will not be deallocated when the thread exits.
> Purify: Searching for all memory leaks...
> Memory leaked: 42 bytes (6.98%); potentially leaked: 0 bytes (0%)
> MLK: 24 bytes leaked at 0x81089d0
>   * This memory was allocated from:
>     malloc         [rtlib.o]
>     operator new(unsigned) [libstd15d.so]
>     __rw::__rw_allocate(unsigned, int) [memory.cpp:53]
>     __rw_tmpbuf    [tmpbuf.cpp:115]
>     std::pair<long long*, int > std::get_temporary_buffer<long long, int >(int, long long*) [_rawiter.h:138]
>     std::pair<long long*, int > std::get_temporary_buffer<long long>(int) [_rawiter.h:153]
> MLK: 18 bytes leaked at 0x8108a38
>   * This memory was allocated from:
>     malloc         [rtlib.o]
>     operator new(unsigned) [libstd15d.so]
>     __rw::__rw_allocate(unsigned, int) [memory.cpp:53]
>     __rw_tmpbuf    [tmpbuf.cpp:115]
>     std::pair<short*, int > std::get_temporary_buffer<short, int >(int, short*) [_rawiter.h:138]
>     std::pair<short*, int > std::get_temporary_buffer<short>(int) [_rawiter.h:153]

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (STDCXX-587) purify reports memory leak from __rw_tmpbuf in 20.temp.buffer.mt

Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-587?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12537081 ] 

Farid Zaripov commented on STDCXX-587:
--------------------------------------

Since rw_opt_nloops is just a counter, how about the following patch?

-----------------
Index: 20.temp.buffer.mt.cpp
===================================================================
--- 20.temp.buffer.mt.cpp	(revision 587473)
+++ 20.temp.buffer.mt.cpp	(working copy)
@@ -48,7 +48,7 @@
 #endif
 
 /* extern */ unsigned rw_opt_nthreads = 4 <= MAX_THREADS ? 4 : MAX_THREADS;
-/* extern */ unsigned rw_opt_nloops   = 1024 * 1024;
+/* extern */ unsigned rw_opt_nloops   = 128 * 1024;
 
 /**************************************************************************/
 
@@ -142,7 +142,7 @@
     std::pair<_RWSTD_INT32_T*, std::ptrdiff_t> buf2;
     std::pair<Type64*,         std::ptrdiff_t> buf3;
 
-    for (unsigned i = 0; i != rw_opt_nloops; ++i) {
+    for (unsigned i = 0; i != rw_opt_nloops * 8; ++i) {
 
         const unsigned nelems = (i + targs->threadno_) % 32;
-----------------


> purify reports memory leak from __rw_tmpbuf in 20.temp.buffer.mt
> ----------------------------------------------------------------
>
>                 Key: STDCXX-587
>                 URL: https://issues.apache.org/jira/browse/STDCXX-587
>             Project: C++ Standard Library
>          Issue Type: Improvement
>          Components: Tests
>            Reporter: Travis Vitek
>            Priority: Minor
>             Fix For: 4.2.1
>
>         Attachments: stdcxx-587.patch
>
>
> Each test thread iterates some number of times switching on a counter. If the last iteration runs one of the allocation functions, the temporary buffer will not be deallocated when the thread exits.
> Purify: Searching for all memory leaks...
> Memory leaked: 42 bytes (6.98%); potentially leaked: 0 bytes (0%)
> MLK: 24 bytes leaked at 0x81089d0
>   * This memory was allocated from:
>     malloc         [rtlib.o]
>     operator new(unsigned) [libstd15d.so]
>     __rw::__rw_allocate(unsigned, int) [memory.cpp:53]
>     __rw_tmpbuf    [tmpbuf.cpp:115]
>     std::pair<long long*, int > std::get_temporary_buffer<long long, int >(int, long long*) [_rawiter.h:138]
>     std::pair<long long*, int > std::get_temporary_buffer<long long>(int) [_rawiter.h:153]
> MLK: 18 bytes leaked at 0x8108a38
>   * This memory was allocated from:
>     malloc         [rtlib.o]
>     operator new(unsigned) [libstd15d.so]
>     __rw::__rw_allocate(unsigned, int) [memory.cpp:53]
>     __rw_tmpbuf    [tmpbuf.cpp:115]
>     std::pair<short*, int > std::get_temporary_buffer<short, int >(int, short*) [_rawiter.h:138]
>     std::pair<short*, int > std::get_temporary_buffer<short>(int) [_rawiter.h:153]

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (STDCXX-587) purify reports memory leak from __rw_tmpbuf in 20.temp.buffer.mt

Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-587?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Farid Zaripov resolved STDCXX-587.
----------------------------------

    Resolution: Fixed

> purify reports memory leak from __rw_tmpbuf in 20.temp.buffer.mt
> ----------------------------------------------------------------
>
>                 Key: STDCXX-587
>                 URL: https://issues.apache.org/jira/browse/STDCXX-587
>             Project: C++ Standard Library
>          Issue Type: Improvement
>          Components: Tests
>    Affects Versions: 4.2.0
>            Reporter: Travis Vitek
>            Assignee: Travis Vitek
>            Priority: Minor
>             Fix For: 4.2.1
>
>         Attachments: stdcxx-587.patch
>
>
> Each test thread iterates some number of times switching on a counter. If the last iteration runs one of the allocation functions, the temporary buffer will not be deallocated when the thread exits.
> Purify: Searching for all memory leaks...
> Memory leaked: 42 bytes (6.98%); potentially leaked: 0 bytes (0%)
> MLK: 24 bytes leaked at 0x81089d0
>   * This memory was allocated from:
>     malloc         [rtlib.o]
>     operator new(unsigned) [libstd15d.so]
>     __rw::__rw_allocate(unsigned, int) [memory.cpp:53]
>     __rw_tmpbuf    [tmpbuf.cpp:115]
>     std::pair<long long*, int > std::get_temporary_buffer<long long, int >(int, long long*) [_rawiter.h:138]
>     std::pair<long long*, int > std::get_temporary_buffer<long long>(int) [_rawiter.h:153]
> MLK: 18 bytes leaked at 0x8108a38
>   * This memory was allocated from:
>     malloc         [rtlib.o]
>     operator new(unsigned) [libstd15d.so]
>     __rw::__rw_allocate(unsigned, int) [memory.cpp:53]
>     __rw_tmpbuf    [tmpbuf.cpp:115]
>     std::pair<short*, int > std::get_temporary_buffer<short, int >(int, short*) [_rawiter.h:138]
>     std::pair<short*, int > std::get_temporary_buffer<short>(int) [_rawiter.h:153]

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.