public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug analyzer/98918] [11 Regression] Analyzer false positives due to sm-state involving UNKNOWN pointers
Date: Mon, 01 Feb 2021 20:14:52 +0000	[thread overview]
Message-ID: <bug-98918-4-rgIeEwgQBD@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98918-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:11d4ec5d45c02a19b8ff9d7f26800637ad563e05

commit r11-7024-g11d4ec5d45c02a19b8ff9d7f26800637ad563e05
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Mon Feb 1 15:13:39 2021 -0500

    analyzer: fix false positives with *UNKNOWN_PTR [PR98918]

    PR analyzer/98918 reports various false positives and state explosions
    on correct code that frees nodes and other pointers in a singly-linked
    list.

    The issue is that state-merger in the loop leads to UNKNOWN_VALUEs,
    and these are then erroneously used to form compound symbolic values
    and regions, such as;
      INIT_VAL((*UNKNOWN(struct marker *)).ref)
    and:
      (*INIT_VAL((*UNKNOWN(struct marker * *))))
    The malloc state machine then treats these symbolic values as
    identifying specific pointers, and thus e.g. erroneously reports a
    double-free when
      INIT_VAL((*UNKNOWN(struct marker *)).ref)
    is freed twice (on subsequent iterations of the loop).

    Similarly, the increasingly complex compound symbolic values have
    sm-state which prevents state merging, and eventually lead to the
    analysis hitting safety limits and stopping.

    This patch makes various compound values involving UNKNOWN be
    themselves UNKNOWN, resolving both the false positives and the state
    explosions.

    gcc/analyzer/ChangeLog:
            PR analyzer/98918
            * region-model-manager.cc
            (region_model_manager::get_or_create_initial_value):
            Fold the initial value of *UNKNOWN_PTR to an UNKNOWN value.
            (region_model_manager::get_field_region): Fold the value
            of UNKNOWN_PTR->FIELD to *UNKNOWN_PTR_OF_&FIELD_TYPE.

    gcc/testsuite/ChangeLog:
            PR analyzer/98918
            * gcc.dg/analyzer/pr98918.c: New test.

  parent reply	other threads:[~2021-02-01 20:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01 15:17 [Bug analyzer/98918] New: " dmalcolm at gcc dot gnu.org
2021-02-01 15:20 ` [Bug analyzer/98918] " dmalcolm at gcc dot gnu.org
2021-02-01 15:23 ` [Bug analyzer/98918] [11 Regression] " dmalcolm at gcc dot gnu.org
2021-02-01 20:14 ` cvs-commit at gcc dot gnu.org [this message]
2021-02-01 20:17 ` 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-98918-4-rgIeEwgQBD@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).