public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Costas Argyris <costas.argyris@gmail.com>
Cc: Jonathan Wakely <jwakely@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] driver: Fix memory leak.
Date: Thu, 7 Dec 2023 16:42:44 +0100	[thread overview]
Message-ID: <ZXHn9HhS7N5vMzVI@tucnak> (raw)
In-Reply-To: <CAHyHGCn-EB8gOd3nxskZ=43k+=z41U+SmLCm4HzSfNPmpJt=uA@mail.gmail.com>

On Thu, Dec 07, 2023 at 03:16:29PM +0000, Costas Argyris wrote:
> >  Still reachable memory at exit e.g. from valgrind is not a bug.
> 
> Indeed, this is coming from a valgrind report here:
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93019
> 
> where it was noted that the driver memory leaks could be
> problematic for JIT.

In the invoke_embedded_driver JIT case yes, that calls driver::finalize (),
which is why it should be freed before clearing the pointer in there (as
then it is a real leak).

> So, since using std::vector did reduce the valgrind records
> by one (I only targeted a single variable to begin with) I took
> that as a good sign.
> 
> Regarding adding a call to XDELETE (mdswitches), yes,
> that would help in the case where driver::finalize () is actually
> called, which I think is for JIT.    I was trying to take care of the
> case where it doesn't get called as well, but from what you say
> I take it that this case is not of interest.

That is wasted compile time on a non-issue.

If you see a JIT issue with definitely lost records, that is something
that obviously should be fixed (but even in that area I think we've been a
little bit lazy in the option handling).
The most important is that the actual compiler binaries (cc1, cc1plus, ...)
don't leak memory (in the definitely lost kind) like crazy, we have
--enable-checking=valgrind
for that purpose, where the driver runs cc1/cc1plus etc. under valgrind,
but this is very expensive and slow, so usually it is run once during a
cycle (if at all), on a fast machine could take even in non-bootstrap mode
a weekend to go through the whole testsuite, then one can look at the leaks.

	Jakub


  reply	other threads:[~2023-12-07 15:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-02 21:24 Costas Argyris
2023-12-04 12:15 ` Jonathan Wakely
2023-12-06 14:29   ` Costas Argyris
2023-12-06 14:39     ` Jakub Jelinek
2023-12-07 14:28       ` Costas Argyris
2023-12-07 14:42         ` Jakub Jelinek
2023-12-07 15:16           ` Costas Argyris
2023-12-07 15:42             ` Jakub Jelinek [this message]
2023-12-07 16:01               ` Costas Argyris
2023-12-07 16:04                 ` Jakub Jelinek
2023-12-08 12:18                   ` Costas Argyris
2023-12-08 13:16                     ` Jakub Jelinek

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=ZXHn9HhS7N5vMzVI@tucnak \
    --to=jakub@redhat.com \
    --cc=costas.argyris@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).