public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "shihua at iscas dot ac.cn" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/103872] New: testcase fail in gcc.dg/analyzer/pr103526.c on riscv64-unknown-elf-gcc
Date: Fri, 31 Dec 2021 06:31:26 +0000	[thread overview]
Message-ID: <bug-103872-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 103872
           Summary: testcase fail in gcc.dg/analyzer/pr103526.c on
                    riscv64-unknown-elf-gcc
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shihua at iscas dot ac.cn
  Target Milestone: ---

analyzer can not properly detects the non-free'd pointer as escaping via the
return value in riscv*-**-gcc



riscv64-unknown-elf-gcc -S -fanalyzer -Wanalyzer-too-complex
-fanalyzer-call-summaries riscv-gcc/gcc/testsuite/gcc.dg/analyzer/pr103526.c
riscv-gcc/gcc/testsuite/gcc.dg/analyzer/pr103526.c: In function 'game_new':
riscv-gcc/gcc/testsuite/gcc.dg/analyzer/pr103526.c:31:1: warning: leak of
'tmp.word_state' [CWE-401] [-Wanalyzer-malloc-leak]
   31 | } /* { dg-bogus "leak" } */
      | ^
  'game_new': events 1-7
    |
    |   20 |         if ((tmp.word_state = malloc(wordlen+1)) == NULL)
    |      |            ~                  ^~~~~~~~~~~~~~~~~
    |      |            |                  |
    |      |            |                  (1) allocated here
    |      |            (2) assuming 'tmp.word_state' is non-NULL
    |      |            (3) following 'false' branch...
    |   21 |                 goto err;
    |   22 |         if ((rval = malloc(sizeof(*rval))) == NULL)
    |      |            ~        ~~~~~~~~~~~~~~~~~~~~~
    |      |            |        |
    |      |            |        (4) ...to here
    |      |            (5) following 'false' branch (when 'rval' is
non-NULL)...
    |   23 |                 goto err;
    |   24 |         memcpy(rval, &tmp, sizeof(*rval));
    |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |         |
    |      |         (6) ...to here
    |......
    |   31 | } /* { dg-bogus "leak" } */
    |      | ~
    |      | |
    |      | (7) 'tmp.word_state' leaks here; was allocated at (1)
    |

             reply	other threads:[~2021-12-31  6:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-31  6:31 shihua at iscas dot ac.cn [this message]
2022-01-28 22:55 ` [Bug analyzer/103872] " pinskia at gcc dot gnu.org
2022-01-28 23:01 ` pinskia at gcc dot gnu.org
2022-02-03 21:21 ` dmalcolm at gcc dot gnu.org
2022-02-07 23:32 ` cvs-commit at gcc dot gnu.org
2022-02-07 23:43 ` dmalcolm at gcc dot gnu.org

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=bug-103872-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).