This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug exp/16537] New: operator+ with strings leaks memory


https://sourceware.org/bugzilla/show_bug.cgi?id=16537

            Bug ID: 16537
           Summary: operator+ with strings leaks memory
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: exp
          Assignee: unassigned at sourceware dot org
          Reporter: dje at google dot com

Created attachment 7397
  --> https://sourceware.org/bugzilla/attachment.cgi?id=7397&action=edit
revised testcase that includes string operator+

Playing with this patch, and extending the testcase to use a string-like class
I see the value being leaked.

https://sourceware.org/ml/gdb-patches/2014-02/msg00005.html

Attached my revised version of the testcase in the above patch.
Here is the script I used to exercise it.
Compare valgrind output with n = 100 vs n = 1000.

valgrind gdb --batch -x loop.gdb

n = 100

==42852== LEAK SUMMARY:
==42852==    definitely lost: 2,216 bytes in 108 blocks
==42852==    indirectly lost: 24 bytes in 1 blocks
==42852==      possibly lost: 458,155 bytes in 3,259 blocks
==42852==    still reachable: 6,622,967 bytes in 15,678 blocks
==42852==         suppressed: 0 bytes in 0 blocks


n = 1000

==42859== LEAK SUMMARY:
==42859==    definitely lost: 13,016 bytes in 1,008 blocks
==42859==    indirectly lost: 24 bytes in 1 blocks
==42859==      possibly lost: 458,155 bytes in 3,259 blocks
==42859==    still reachable: 6,622,967 bytes in 15,678 blocks
==42859==         suppressed: 0 bytes in 0 blocks


---snip---
file testsuite/gdb.python/py-value-cc
start
b 131
c

py s1 = gdb.parse_and_eval ("s1")
py s2 = gdb.parse_and_eval ("s2")

set $i = 0
set $n = 1000

while $i < $n
  py s3 = s1 + s2
  set $i = $i + 1
end

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]