public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dmalcolm at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug analyzer/106573] New: Missing -Wanalyzer-use-of-uninitialized-value on calls handled by state machines
Date: Tue, 09 Aug 2022 19:51:58 +0000	[thread overview]
Message-ID: <bug-106573-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 106573
           Summary: Missing -Wanalyzer-use-of-uninitialized-value on calls
                    handled by state machines
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
                CC: mir at gcc dot gnu.org
  Target Milestone: ---

Consider:

int dup (int old_fd);
int not_dup (int old_fd);

int
test_1 ()
{
  int m;
  return dup (m);
}

int
test_2 ()
{
  int m;
  return not_dup (m);
}

where in each function uninitialized local "m" is passed to an
externally-defined function.

-fanalyzer currently emits:

t.c: In function ‘test_1’:
t.c:8:10: warning: ‘dup’ on possibly invalid file descriptor ‘m’
[-Wanalyzer-fd-use-without-check]
    8 |   return dup (m);
      |          ^~~~~~~
  ‘test_1’: event 1
    |
    |    8 |   return dup (m);
    |      |          ^~~~~~~
    |      |          |
    |      |          (1) ‘m’ could be invalid
    |
t.c: In function ‘test_2’:
t.c:15:10: warning: use of uninitialized value ‘m’ [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
   15 |   return not_dup (m);
      |          ^~~~~~~~~~~
  ‘test_2’: events 1-2
    |
    |   14 |   int m;
    |      |       ^
    |      |       |
    |      |       (1) region created on stack here
    |   15 |   return not_dup (m);
    |      |          ~~~~~~~~~~~
    |      |          |
    |      |          (2) use of uninitialized value ‘m’ here
    |

where it only complains about uninit m being passed to not_dup.

Looks like we're missing a check for poisoned svalues as params for the case
where one of the state machines recognizes the function in question.

             reply	other threads:[~2022-08-09 19:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-09 19:51 dmalcolm at gcc dot gnu.org [this message]
2022-08-09 20:33 ` [Bug analyzer/106573] " dmalcolm at gcc dot gnu.org
2022-08-10  0:01 ` cvs-commit at gcc dot gnu.org
2022-08-10  0:07 ` dmalcolm at gcc dot gnu.org
2022-08-15 18:48 ` cvs-commit at gcc dot gnu.org
2023-03-29 18:18 ` cvs-commit at gcc dot gnu.org
2023-03-29 18:18 ` cvs-commit 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-106573-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).