public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug exp/16537] New: operator+ with strings leaks memory
@ 2014-02-07  6:49 dje at google dot com
  2024-01-10 18:35 ` [Bug exp/16537] " ssbssa at sourceware dot org
  0 siblings, 1 reply; 2+ messages in thread
From: dje at google dot com @ 2014-02-07  6:49 UTC (permalink / raw)
  To: gdb-prs

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug exp/16537] operator+ with strings leaks memory
  2014-02-07  6:49 [Bug exp/16537] New: operator+ with strings leaks memory dje at google dot com
@ 2024-01-10 18:35 ` ssbssa at sourceware dot org
  0 siblings, 0 replies; 2+ messages in thread
From: ssbssa at sourceware dot org @ 2024-01-10 18:35 UTC (permalink / raw)
  To: gdb-prs

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

Hannes Domani <ssbssa at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ssbssa at sourceware dot org

--- Comment #1 from Hannes Domani <ssbssa at sourceware dot org> ---
Isn't it 'by design' that gdb never calls destructors of return values in
expressions?

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-10 18:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-07  6:49 [Bug exp/16537] New: operator+ with strings leaks memory dje at google dot com
2024-01-10 18:35 ` [Bug exp/16537] " ssbssa at sourceware dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).