public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "dje at google dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug exp/16537] New: operator+ with strings leaks memory
Date: Fri, 07 Feb 2014 06:49:00 -0000	[thread overview]
Message-ID: <bug-16537-4717@http.sourceware.org/bugzilla/> (raw)

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.


             reply	other threads:[~2014-02-07  6:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-07  6:49 dje at google dot com [this message]
2024-01-10 18:35 ` [Bug exp/16537] " ssbssa at sourceware dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-16537-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).