public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4219] analyzer: fix ICE on writes to errno [PR107777] Date: Tue, 22 Nov 2022 00:10:08 +0000 (GMT) [thread overview] Message-ID: <20221122001008.4F56A384F6D5@sourceware.org> (raw) https://gcc.gnu.org/g:358dab90186b30a5d287710f13625c327210218d commit r13-4219-g358dab90186b30a5d287710f13625c327210218d Author: David Malcolm <dmalcolm@redhat.com> Date: Mon Nov 21 19:08:17 2022 -0500 analyzer: fix ICE on writes to errno [PR107777] gcc/analyzer/ChangeLog: PR analyzer/107777 * call-summary.cc (call_summary_replay::convert_region_from_summary_1): Handle RK_THREAD_LOCAL and RK_ERRNO in switch. * region-model.cc (region_model::get_representative_path_var_1): Likewise. gcc/testsuite/ChangeLog: PR analyzer/107777 * gcc.dg/analyzer/call-summaries-errno.c: New test. * gcc.dg/analyzer/errno-pr107777.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com> Diff: --- gcc/analyzer/call-summary.cc | 2 ++ gcc/analyzer/region-model.cc | 2 ++ gcc/testsuite/gcc.dg/analyzer/call-summaries-errno.c | 17 +++++++++++++++++ gcc/testsuite/gcc.dg/analyzer/errno-pr107777.c | 20 ++++++++++++++++++++ 4 files changed, 41 insertions(+) diff --git a/gcc/analyzer/call-summary.cc b/gcc/analyzer/call-summary.cc index ebc7b5028ec..4c4694b5381 100644 --- a/gcc/analyzer/call-summary.cc +++ b/gcc/analyzer/call-summary.cc @@ -575,6 +575,7 @@ call_summary_replay::convert_region_from_summary_1 (const region *summary_reg) case RK_CODE: case RK_STACK: case RK_HEAP: + case RK_THREAD_LOCAL: case RK_ROOT: /* These should never be pointed to by a region_svalue. */ gcc_unreachable (); @@ -582,6 +583,7 @@ call_summary_replay::convert_region_from_summary_1 (const region *summary_reg) case RK_FUNCTION: case RK_LABEL: case RK_STRING: + case RK_ERRNO: case RK_UNKNOWN: /* We can reuse these regions directly. */ return summary_reg; diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index 81f58a59f4f..1d5b09a6805 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -4754,6 +4754,7 @@ region_model::get_representative_path_var_1 (const region *reg, case RK_CODE: case RK_HEAP: case RK_STACK: + case RK_THREAD_LOCAL: case RK_ROOT: /* Regions that represent memory spaces are not expressible as trees. */ return path_var (NULL_TREE, 0); @@ -4873,6 +4874,7 @@ region_model::get_representative_path_var_1 (const region *reg, } case RK_VAR_ARG: + case RK_ERRNO: case RK_UNKNOWN: return path_var (NULL_TREE, 0); } diff --git a/gcc/testsuite/gcc.dg/analyzer/call-summaries-errno.c b/gcc/testsuite/gcc.dg/analyzer/call-summaries-errno.c new file mode 100644 index 00000000000..e4333b30bb7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/call-summaries-errno.c @@ -0,0 +1,17 @@ +/* { dg-additional-options "-fanalyzer-call-summaries" } */ + +#include <errno.h> +#include "analyzer-decls.h" + +void sets_errno (int x) +{ + errno = x; +} + +void test_sets_errno (int y) +{ + sets_errno (y); + sets_errno (y); + + __analyzer_eval (errno == y); /* { dg-warning "TRUE" } */ +} diff --git a/gcc/testsuite/gcc.dg/analyzer/errno-pr107777.c b/gcc/testsuite/gcc.dg/analyzer/errno-pr107777.c new file mode 100644 index 00000000000..65687393657 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/errno-pr107777.c @@ -0,0 +1,20 @@ +int * +__errno_location (void); + +long int +read (int, void *, unsigned long int); + +struct IOBUF { + int fd; +}; + +void +do_getline_end_data (struct IOBUF *iop, int tree) +{ + char end_data; + + if (tree) + *__errno_location () = 0; + + read (iop->fd, &end_data, sizeof end_data); +}
reply other threads:[~2022-11-22 0:10 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=20221122001008.4F56A384F6D5@sourceware.org \ --to=dmalcolm@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).