From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7879) id A1E40385842B; Wed, 15 Feb 2023 10:23:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A1E40385842B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676456639; bh=yhSNpG+VV+yxE27ZYPrQA5MNRd7WXGApQwyt33Tsryo=; h=From:To:Subject:Date:From; b=LMMjXTuqdwPdHNg5IORKeVcqISFE7190yZC/BXuMBucwhEsSG829piosJK36k6NQq DmJI9lRyAftad7rST5xDFt38WkTh7uygQiFamz01rImYc1B9Hq1A9/44r/sxRjCGnF 9xhe4XWRSIireYATz3gdsaJg98s7MrY4AMUgqMEk= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Filip Kastl To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/pheeck/heads/sccp)] asan: Fix up error recovery for too large frames [PR107317] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/users/pheeck/heads/sccp X-Git-Oldrev: 1d8296fbdb68134ce11884716bcf1d9b9abcd565 X-Git-Newrev: 51c4ecb161e67dd58cc735bd2c303a20c383a863 Message-Id: <20230215102359.A1E40385842B@sourceware.org> Date: Wed, 15 Feb 2023 10:23:59 +0000 (GMT) List-Id: https://gcc.gnu.org/g:51c4ecb161e67dd58cc735bd2c303a20c383a863 commit 51c4ecb161e67dd58cc735bd2c303a20c383a863 Author: Jakub Jelinek Date: Thu Nov 24 11:29:54 2022 +0100 asan: Fix up error recovery for too large frames [PR107317] asan_emit_stack_protection and functions it calls have various asserts that verify sanity of the stack protection instrumentation. But, that verification can easily fail if we've diagnosed a frame offset overflow. asan_emit_stack_protection just emits some extra code in the prologue, if we've reported errors, we aren't producing assembly, so it doesn't really matter if we don't include the protection code, compilation is going to fail anyway. 2022-11-24 Jakub Jelinek PR middle-end/107317 * asan.cc: Include diagnostic-core.h. (asan_emit_stack_protection): Return NULL early if seen_error (). * gcc.dg/asan/pr107317.c: New test. Diff: --- gcc/asan.cc | 6 ++++++ gcc/testsuite/gcc.dg/asan/pr107317.c | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/gcc/asan.cc b/gcc/asan.cc index 8276f12cc69..dc7b7f4bcf1 100644 --- a/gcc/asan.cc +++ b/gcc/asan.cc @@ -64,6 +64,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-inline.h" #include "tree-ssa.h" #include "tree-eh.h" +#include "diagnostic-core.h" /* AddressSanitizer finds out-of-bounds and use-after-free bugs with <2x slowdown on average. @@ -1818,6 +1819,11 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb, tree str_cst, decl, id; int use_after_return_class = -1; + /* Don't emit anything when doing error recovery, the assertions + might fail e.g. if a function had a frame offset overflow. */ + if (seen_error ()) + return NULL; + if (shadow_ptr_types[0] == NULL_TREE) asan_init_shadow_ptr_types (); diff --git a/gcc/testsuite/gcc.dg/asan/pr107317.c b/gcc/testsuite/gcc.dg/asan/pr107317.c new file mode 100644 index 00000000000..dd7ad7d2449 --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr107317.c @@ -0,0 +1,13 @@ +/* PR middle-end/107317 */ +/* { dg-do compile { target ilp32 } } */ +/* { dg-options "-fsanitize=address -ffat-lto-objects" } */ + +void bar (float *, float *); + +void +foo (void) /* { dg-error "exceeds maximum" } */ +{ + float a[400000000]; + float b[200000000]; + bar (a, b); +}