public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/99004] New: memory leak in maybe_warn_rdwr_sizes
@ 2021-02-08 14:55 rguenth at gcc dot gnu.org
  2021-02-08 16:52 ` [Bug middle-end/99004] " jakub at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-02-08 14:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99004

            Bug ID: 99004
           Summary: memory leak in maybe_warn_rdwr_sizes
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

==3511== Memcheck, a memory error detector
==3511== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==3511== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==3511== Command: ./cc1 -quiet -fdiagnostics-plain-output -O3 -o
ssa-dom-thread-1.s
/home/rguenther/src/gcc3/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf.c
==3511==
==3511==
==3511== HEAP SUMMARY:
==3511==     in use at exit: 2,402,368 bytes in 5,697 blocks
==3511==   total heap usage: 424,419 allocs, 418,722 frees, 208,122,638 bytes
allocated
==3511==
==3511== 2 bytes in 1 blocks are definitely lost in loss record 1 of 921
==3511==    at 0x4C2E2DF: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==3511==    by 0x28ECDF6: xmalloc (xmalloc.c:147)
==3511==    by 0x28ECF6F: xstrdup (xstrdup.c:34)
==3511==    by 0x15EF51F: print_generic_expr_to_str(tree_node*)
(tree-pretty-print.c:179)
==3511==    by 0xC532AD: maybe_warn_rdwr_sizes(hash_map<rdwr_access_hash,
attr_access, simple_hashmap_traits<default_hash_traits<rdwr_access_hash>,
attr_access> >*, tree_node*, tree_node*, tree_node*) (calls.c:2035)
==3511==    by 0xC5535F: initialize_argument_information(int, arg_data*,
args_size*, int, tree_node*, tree_node*, tree_node*, tree_node*,
cumulative_args_t, int, rtx_def**, poly_int_pod<1u, long>*, int*, int*, bool*,
bool) (calls.c:2625)
==3511==    by 0xC5957C: expand_call(tree_node*, rtx_def*, int) (calls.c:4009)
==3511==    by 0xE84D06: expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool) (expr.c:11279)
==3511==    by 0xE77230: expand_expr_real(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool) (expr.c:8513)
==3511==    by 0xC7C8EA: expand_expr(tree_node*, rtx_def*, machine_mode,
expand_modifier) (expr.h:282)
==3511==    by 0xC858B6: expand_call_stmt(gcall*) (cfgexpand.c:2840)
==3511==    by 0xC8933E: expand_gimple_stmt_1(gimple*) (cfgexpand.c:3844)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/99004] memory leak in maybe_warn_rdwr_sizes
  2021-02-08 14:55 [Bug middle-end/99004] New: memory leak in maybe_warn_rdwr_sizes rguenth at gcc dot gnu.org
@ 2021-02-08 16:52 ` jakub at gcc dot gnu.org
  2021-02-09 11:30 ` cvs-commit at gcc dot gnu.org
  2021-02-09 11:34 ` jakub at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-08 16:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99004

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-02-08
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 50144
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50144&action=edit
gcc11-pr99004.patch

Untested fix.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/99004] memory leak in maybe_warn_rdwr_sizes
  2021-02-08 14:55 [Bug middle-end/99004] New: memory leak in maybe_warn_rdwr_sizes rguenth at gcc dot gnu.org
  2021-02-08 16:52 ` [Bug middle-end/99004] " jakub at gcc dot gnu.org
@ 2021-02-09 11:30 ` cvs-commit at gcc dot gnu.org
  2021-02-09 11:34 ` jakub at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-09 11:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99004

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:e5304598f1481886f9871cc024cb65ba34aa4be3

commit r11-7145-ge5304598f1481886f9871cc024cb65ba34aa4be3
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Feb 9 12:29:32 2021 +0100

    calls: Fix a memory leak in maybe_warn_rdwr_sizes [PR99004]

    The print_generic_expr_to_str function ends with
    return xstrdup (...); and therefore expects the caller to free
    the argument.

    The following patch does that after it has been copied.
    Instead of doing const_cast to cast away const char * to char *,
    because the code uses s0 and s1 in so few places, I chose just
    to change the types of the two variables so that const_cast
    is not needed.  After all, it is a heap allocated string that
    this function owns and so if it wanted, it could change it too.

    2021-02-09  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/99004
            * calls.c (maybe_warn_rdwr_sizes): Change s0 and s1 type from
            const char * to char * and free those pointers after use.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/99004] memory leak in maybe_warn_rdwr_sizes
  2021-02-08 14:55 [Bug middle-end/99004] New: memory leak in maybe_warn_rdwr_sizes rguenth at gcc dot gnu.org
  2021-02-08 16:52 ` [Bug middle-end/99004] " jakub at gcc dot gnu.org
  2021-02-09 11:30 ` cvs-commit at gcc dot gnu.org
@ 2021-02-09 11:34 ` jakub at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-09 11:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99004

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-02-09 11:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08 14:55 [Bug middle-end/99004] New: memory leak in maybe_warn_rdwr_sizes rguenth at gcc dot gnu.org
2021-02-08 16:52 ` [Bug middle-end/99004] " jakub at gcc dot gnu.org
2021-02-09 11:30 ` cvs-commit at gcc dot gnu.org
2021-02-09 11:34 ` jakub at gcc dot gnu.org

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).