From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [committed] analyzer: fix ICE on realloc of non-heap [PR104417]
Date: Mon, 7 Feb 2022 18:38:17 -0500 [thread overview]
Message-ID: <20220207233817.43212-1-dmalcolm@redhat.com> (raw)
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r12-7087-g0c04ac0e15830b.
gcc/analyzer/ChangeLog:
PR analyzer/104417
* sm-taint.cc (tainted_allocation_size::tainted_allocation_size):
Remove overzealous assertion.
(tainted_allocation_size::emit): Likewise.
(region_model::check_dynamic_size_for_taint): Likewise.
gcc/testsuite/ChangeLog:
PR analyzer/104417
* gcc.dg/analyzer/pr104417.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
---
gcc/analyzer/sm-taint.cc | 9 ---------
gcc/testsuite/gcc.dg/analyzer/pr104417.c | 7 +++++++
2 files changed, 7 insertions(+), 9 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/analyzer/pr104417.c
diff --git a/gcc/analyzer/sm-taint.cc b/gcc/analyzer/sm-taint.cc
index 573a9124286..57a0ac684ab 100644
--- a/gcc/analyzer/sm-taint.cc
+++ b/gcc/analyzer/sm-taint.cc
@@ -496,9 +496,6 @@ public:
: taint_diagnostic (sm, arg, has_bounds),
m_mem_space (mem_space)
{
- gcc_assert (mem_space == MEMSPACE_STACK
- || mem_space == MEMSPACE_HEAP
- || mem_space == MEMSPACE_UNKNOWN);
}
const char *get_kind () const FINAL OVERRIDE
@@ -511,9 +508,6 @@ public:
diagnostic_metadata m;
/* "CWE-789: Memory Allocation with Excessive Size Value". */
m.add_cwe (789);
- gcc_assert (m_mem_space == MEMSPACE_STACK
- || m_mem_space == MEMSPACE_HEAP
- || m_mem_space == MEMSPACE_UNKNOWN);
// TODO: make use of m_mem_space
if (m_arg)
switch (m_has_bounds)
@@ -1055,9 +1049,6 @@ region_model::check_dynamic_size_for_taint (enum memory_space mem_space,
const svalue *size_in_bytes,
region_model_context *ctxt) const
{
- gcc_assert (mem_space == MEMSPACE_STACK
- || mem_space == MEMSPACE_HEAP
- || mem_space == MEMSPACE_UNKNOWN);
gcc_assert (size_in_bytes);
gcc_assert (ctxt);
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr104417.c b/gcc/testsuite/gcc.dg/analyzer/pr104417.c
new file mode 100644
index 00000000000..41ea5dbd0c7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr104417.c
@@ -0,0 +1,7 @@
+char eparr[1];
+
+void *
+warn_realloc_extern_ptrarr_offset (int i, int n)
+{
+ return __builtin_realloc (eparr + i, n); /* { dg-warning "'__builtin_realloc' called on unallocated object 'eparr'" } */
+}
--
2.26.3
reply other threads:[~2022-02-07 23:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220207233817.43212-1-dmalcolm@redhat.com \
--to=dmalcolm@redhat.com \
--cc=gcc-patches@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).