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/107711] [13 Regression] ICE with "-fanalyzer -Wunused-macros" since  r13-4073-gd8aba860b34203
Date: Thu, 17 Nov 2022 17:36:06 +0000	[thread overview]
Message-ID: <bug-107711-4-s58nZfFFyD@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107711-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #11 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:f9ed1d24ee46f5ca759c35a1f51fa163d7529ea6

commit r13-4130-gf9ed1d24ee46f5ca759c35a1f51fa163d7529ea6
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Thu Nov 17 12:34:56 2022 -0500

    c, analyzer: fix ICE with -fanalyzer and -Wunused-macros [PR107711]

    PR analyzer/107711 reports an ICE since r13-4073-gd8aba860b34203 with
    the combination of -fanalyzer and -Wunused-macros.

    The issue is that in c_translation_unit::consider_macro's call to
    cpp_create_reader I was passing "ident_hash" for use by the the new
    reader, but that takes ownership of that hash_table, so that ident_hash
    erroneously gets freed when c_translation_unit::consider_macro calls
    cpp_destroy, leading to a use-after-free in -Wunused-macros, where:

    (gdb) p pfile->hash_table->pfile == pfile
    $23 = false

    and it's instead pointing at the freed reader from consider_macro,
    leading to a use-after-free ICE.

    Fixed thusly.

    gcc/c/ChangeLog:
            PR analyzer/107711
            * c-parser.cc (ana::c_translation_unit::consider_macro): Pass NULL
            to cpp_create_reader, rather than ident_hash, so that the new
            reader gets its own hash table.

    gcc/testsuite/ChangeLog:
            PR analyzer/107711
            * gcc.dg/analyzer/named-constants-Wunused-macros.c: New test.

    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

  parent reply	other threads:[~2022-11-17 17:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16  0:33 [Bug analyzer/107711] New: internal compiler error: Segmentation fault urs at akk dot org
2022-11-16 14:41 ` [Bug analyzer/107711] " dmalcolm at gcc dot gnu.org
2022-11-16 15:26 ` urs at akk dot org
2022-11-16 15:50 ` dmalcolm at gcc dot gnu.org
2022-11-16 15:54 ` dmalcolm at gcc dot gnu.org
2022-11-16 19:41 ` urs at akk dot org
2022-11-16 19:50 ` urs at akk dot org
2022-11-16 21:15 ` [Bug analyzer/107711] ICE with -fanalyzer with -Wunused-macros since r13-4073-gd8aba860b34203 dmalcolm at gcc dot gnu.org
2022-11-16 22:45 ` [Bug analyzer/107711] [13 Regression] ICE with "-fanalyzer -Wunused-macros" " cvs-commit at gcc dot gnu.org
2022-11-16 23:18 ` dmalcolm at gcc dot gnu.org
2022-11-17  3:07 ` dmalcolm at gcc dot gnu.org
2022-11-17 17:36 ` cvs-commit at gcc dot gnu.org [this message]
2022-11-17 17:36 ` dmalcolm at gcc dot gnu.org
2022-11-28 22:24 ` pinskia 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-107711-4-s58nZfFFyD@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).