Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: Pedro Alves <palves@redhat.com>,
	gdb-patches <gdb-patches@sourceware.org>,
		Jerome Guitton <guitton@adacore.com>
Subject: Re: [RFA/commit] Memory leak in on reading frame register
Date: Fri, 15 May 2015 22:35:00 -0000	[thread overview]
Message-ID: <CADPb22TgSUX6zj9SGd_1cgfmHOnhr4i1ecDy7qozigDOG_1qCA@mail.gmail.com> (raw)
In-Reply-To: <20150515155823.GL4767@adacore.com>

On Fri, May 15, 2015 at 8:58 AM, Joel Brobecker <brobecker@adacore.com> wrote:
>> >> Not sure about this.
>> >>
>> >> How come this in bpstat_check_breakpoint_conditions didn't
>> >> handle this issue already? :
>> >>
>> >> ...
>> >>       /* We use value_mark and value_free_to_mark because it could
>> >>     be a long time before we return to the command level and
>> >>     call free_all_values.  We can't call free_all_values
>> >>     because we might be in the middle of evaluating a
>> >>     function call.  */
>> >>       struct value *mark = value_mark ();
>> >>
>> >> ...
>> >>       value_free_to_mark (mark);
>> >
>> > An excellent question, which I will try to research in the next
>> > couple of days!
>>
>> Thanks.  I wonder whether the leaks come from constructing the
>> current frame at each stop, instead of from evaluating
>> breakpoint conditions.  E.g.., if we do a "step" over:
>>
>>    while (1);
>>
>> ... are we constantly leaking values until the user does
>> ctrl-c?
>>
>> That would suggest to me to that we should be doing
>> value_mark/value_free_to_mark around each
>> handle_inferior_event.
>
> A very accurate guess, as it turns out. Condition evaluation
> is not the problem, here, but indeed, we a couple of calls to
> handle_inferior in addition to each call to
> bpstat_check_breakpoint_conditions. The former are responsible
> for the leak.
>
> How about the attached patch?
>
> gdb/ChangeLog:
>
>         * infrun.c (handle_inferior_event_1): Renames handle_inferior_event.
>         (handle_inferior_event): New function.
>
> Tested on x86_64-linux. No regression.

Not that this has to be changed here, but I'm wondering why all value mark/frees
aren't done via cleanups. I can imagine sometimes it's not,
technically, necessary,
and I can imagine there's some history/inertia here,
but having two ways to do this (using a cleanup or not) leaves the reader
having to wonder if using a cleanup was errantly skipped.


  reply	other threads:[~2015-05-15 22:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-08 15:55 Joel Brobecker
2015-05-11 10:55 ` Pedro Alves
2015-05-11 20:53   ` Joel Brobecker
2015-05-12  9:43     ` Pedro Alves
2015-05-15 15:58       ` Joel Brobecker
2015-05-15 22:35         ` Doug Evans [this message]
2015-05-16  0:03           ` Joel Brobecker
2015-05-19 10:04         ` Pedro Alves
2015-05-20  7:39           ` pushed: " Joel Brobecker

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=CADPb22TgSUX6zj9SGd_1cgfmHOnhr4i1ecDy7qozigDOG_1qCA@mail.gmail.com \
    --to=dje@google.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=guitton@adacore.com \
    --cc=palves@redhat.com \
    /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