[PATCH 03/08] PR jit/63854: Fix leak in real.c for i386:init_ext_80387_constants

Richard Biener richard.guenther@gmail.com
Wed Nov 26 10:19:00 GMT 2014


On Wed, Nov 26, 2014 at 2:39 AM, David Malcolm <dmalcolm@redhat.com> wrote:
> Valgrind of testsuite/jit.dg/test-types.c showed this leak in real.c
> when converting the strings in init_ext_80387_constants to real.
>
> 160 bytes in 5 blocks are definitely lost in loss record 89 of 144
>    at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
>    by 0x30AF40C368: __gmp_default_allocate (memory.c:44)
>    by 0x309842EA20: mpfr_init2 (init2.c:55)
>    by 0x527C033: real_from_string(real_value*, char const*) (real.c:2045)
>    by 0x56F0CEF: init_ext_80387_constants() (i386.c:9200)
>    by 0x56F0E4A: standard_80387_constant_p(rtx_def*) (i386.c:9237)
>    by 0x5740115: ix86_rtx_costs(rtx_def*, int, int, int, int*, bool) (i386.c:41735)
>    by 0x52E4417: rtx_cost(rtx_def*, rtx_code, int, bool) (rtlanal.c:3855)
>    by 0x4F28E9C: set_src_cost(rtx_def*, bool) (rtl.h:2111)
>    by 0x4F33AFB: compress_float_constant(rtx_def*, rtx_def*) (expr.c:3667)
>    by 0x4F3380E: emit_move_insn(rtx_def*, rtx_def*) (expr.c:3590)
>    by 0x4F3A1B6: store_expr_with_bounds(tree_node*, rtx_def*, int, bool, tree_node*) (expr.c:5540)
>
> Fix it.

Ok.

Thanks,
Richard.

> gcc/ChangeLog:
>         PR jit/63854
>         * real.c (real_from_string): Add missing mpfr_clear.
> ---
>  gcc/real.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/gcc/real.c b/gcc/real.c
> index cebbe8d..5e8050d 100644
> --- a/gcc/real.c
> +++ b/gcc/real.c
> @@ -2067,6 +2067,7 @@ real_from_string (REAL_VALUE_TYPE *r, const char *str)
>           gcc_assert (r->cl = rvc_normal);
>           /* Set a sticky bit if mpfr_strtofr was inexact.  */
>           r->sig[0] |= inexact;
> +         mpfr_clear (m);
>         }
>      }
>
> --
> 1.8.5.3
>



More information about the Gcc-patches mailing list