public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: marxin <mliska@suse.cz>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 6/9] Fix memory leak in ipa-pure-const
Date: Thu, 19 May 2016 11:18:00 -0000	[thread overview]
Message-ID: <CAFiYyc1==RTJo7BhkTZq=fqF4TErtAdJuLZ0uqM1_C1Km10BBA@mail.gmail.com> (raw)
In-Reply-To: <48c65b302a09f22a20cb299a892ddb3eeb6625d7.1463654693.git.mliska@suse.cz>

On Thu, May 19, 2016 at 12:44 PM, marxin <mliska@suse.cz> wrote:
> Leak can be seen e.g. here:
> gcc i386/mvc6.c -fno-diagnostics-show-caret -fdiagnostics-color=never -O3

Ok.

Richard.

> gcc/ChangeLog:
>
> 2016-05-18  Martin Liska  <mliska@suse.cz>
>
>         * ipa-pure-const.c (set_function_state): Remove an existing
>         funct_state.
>         (remove_node_data): Do not free it as it's released
>         in set_function_state.
> ---
>  gcc/ipa-pure-const.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
> index ba76275..a9570e4 100644
> --- a/gcc/ipa-pure-const.c
> +++ b/gcc/ipa-pure-const.c
> @@ -258,6 +258,13 @@ set_function_state (struct cgraph_node *node, funct_state s)
>    if (!funct_state_vec.exists ()
>        || funct_state_vec.length () <= (unsigned int)node->uid)
>       funct_state_vec.safe_grow_cleared (node->uid + 1);
> +
> +  /* If funct_state_vec already contains a funct_state, we have to release
> +     it before it's going to be ovewritten.  */
> +  if (funct_state_vec[node->uid] != NULL
> +      && funct_state_vec[node->uid] != &varying_state)
> +    free (funct_state_vec[node->uid]);
> +
>    funct_state_vec[node->uid] = s;
>  }
>
> @@ -956,12 +963,7 @@ static void
>  remove_node_data (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED)
>  {
>    if (has_function_state (node))
> -    {
> -      funct_state l = get_function_state (node);
> -      if (l != &varying_state)
> -        free (l);
> -      set_function_state (node, NULL);
> -    }
> +    set_function_state (node, NULL);
>  }
>
>
> --
> 2.8.2
>
>

      reply	other threads:[~2016-05-19 11:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-19 10:47 [PATCH 0/9] Remove various memory leaks marxin
2016-05-19 10:47 ` [PATCH 4/9] Fix memory leak in omp-simd-clone.c marxin
2016-05-19 10:50   ` Jakub Jelinek
2016-05-19 10:47 ` [PATCH 2/9] Fix leak in tree-ssa-loop-prefetch.c marxin
2016-05-19 11:16   ` Richard Biener
2016-05-19 10:47 ` [PATCH 3/9] Fix leak in gcc/tree-ssa-reassoc.c marxin
2016-05-19 11:16   ` Richard Biener
2016-05-19 10:47 ` [PATCH 7/9] Fix memory leak in tree-if-conv.c marxin
2016-05-19 11:16   ` Richard Biener
2016-05-19 10:47 ` [PATCH 5/9] Fix memory leak in tree-vect-slp.c marxin
2016-05-19 11:15   ` Richard Biener
2016-05-19 10:47 ` [PATCH 1/9] Change ENABLE_VALGRIND_CHECKING to ENABLE_VALGRIND_ANNOTATIONS guard marxin
2016-05-19 18:41   ` Jeff Law
2016-05-19 10:47 ` [PATCH 8/9] Fix memory leak in tree-parloops.c marxin
2016-05-19 11:17   ` Richard Biener
2016-05-19 11:03 ` [PATCH 9/9] Fix memory leak in tree-vect-stmts.c marxin
2016-05-19 11:17   ` Richard Biener
2016-05-19 11:05 ` [PATCH 6/9] Fix memory leak in ipa-pure-const marxin
2016-05-19 11:18   ` Richard Biener [this message]

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='CAFiYyc1==RTJo7BhkTZq=fqF4TErtAdJuLZ0uqM1_C1Km10BBA@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mliska@suse.cz \
    /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).