From patchwork Thu Nov 24 09:27:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 25404 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3285357wrr; Thu, 24 Nov 2022 01:29:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf4JdUSII2/wqkG1Z3o6pq7TblWwEDi5/6Y9YhxbdrndhvNKQt2Aoc3ww36P3RAm1CLde8xJ X-Received: by 2002:a05:6402:294b:b0:458:cd82:91a with SMTP id ed11-20020a056402294b00b00458cd82091amr28967148edb.15.1669282149894; Thu, 24 Nov 2022 01:29:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669282149; cv=none; d=google.com; s=arc-20160816; b=RldUYAITnX3gBQuBIEO8GrfZWc8KNTF7qEbQ1h2t5MsAp9lmfyg/SLfuoZdHhXuQA4 hUcUtCq1BO8xHfpqBGT6PPXfnw1FhUyvhpL/Bd5QKnqfxmrD77xS0W0aQ9/xFcu7JRAa wqpZroM4EHq8eWOwBmfQeZSTtXQ0keDMeakDKC3ml+KLXMZPEH6pahvpehtJYaD4iF5m XXIm7znB6gvadyt67GZdwGuk6mbGCzHHu4mKo0D36/TB/SAdxFPZd3mfNzcT8/oRxQV5 F8u5tUGmQ56eHfFkKDBFdWvfwvuv/+DmB7Ynie+uBun5aWtzksNLJCSyZQ1Nwtes7EKL +BPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=OVRAk8KEbhPrXvsISrn+lpfeZaYpgDNtAazemRslTGQ=; b=s29c920UkA9ShOrk0D3iG23Tm61XQj4fl4zLofPZedm/NxA5DclURF1MGqZR30mpeb 2RVb8SRis2+LyGkNN4Liy0I9Rd9ad6+H28uWsaTrGZX2jPlkuhGL/iKndvke5VQdp/oa dVrk+a4QBlAcBcBTe5BdTelTlI11zPYNWvvz7sfWXtcGtjyEF/mo1K/ENND8C/LkNdHn fnxwPi7C0aHUM/Rg8jmptJ9uPsuJIZb+n3BPGHz5+MYZu716TOE6JWJii32PapARy3pL cMJUtvgdICDk58LTll0mxfFvYcE10JCaH5Zz/RgtQBEkWKjC9BrgTOuMhlsQMcM5badH +XRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Wiw7DQoC; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id xh13-20020a170906da8d00b007a6384d506csi484306ejb.643.2022.11.24.01.29.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 01:29:09 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Wiw7DQoC; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AD6A038432EE for ; Thu, 24 Nov 2022 09:29:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD6A038432EE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669282148; bh=OVRAk8KEbhPrXvsISrn+lpfeZaYpgDNtAazemRslTGQ=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Wiw7DQoC6p9MiURXC81tcqrNV0tgDEnLrdXbKTx9Y0aMjhCZnVUzlQofhpk/Hm6Bm FQY7/N3VnlDrGMunNRU0kO1N9/K+0aNXK6tJmEjf4xMiOHZU5dWPgZTQct8lAB4Xju 7o1V6bjYmPy2pF+n7W7ouo99PTBp+soSdYojczA8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 555B9385222B for ; Thu, 24 Nov 2022 09:27:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 555B9385222B Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-98-NpiCwB_jN4Wp1gPiAaWYew-1; Thu, 24 Nov 2022 04:27:32 -0500 X-MC-Unique: NpiCwB_jN4Wp1gPiAaWYew-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2527B833A1E; Thu, 24 Nov 2022 09:27:32 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.202]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D66222024CBE; Thu, 24 Nov 2022 09:27:31 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 2AO9RQuS222330 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 24 Nov 2022 10:27:27 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2AO9RPqZ222329; Thu, 24 Nov 2022 10:27:25 +0100 Date: Thu, 24 Nov 2022 10:27:25 +0100 To: Richard Biener , Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] asan: Fix up error recovery for too large frames [PR107317] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750369199817356655?= X-GMAIL-MSGID: =?utf-8?q?1750369199817356655?= Hi! 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. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 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. Jakub --- gcc/asan.cc.jj 2022-06-28 13:03:30.613693889 +0200 +++ gcc/asan.cc 2022-11-23 17:47:09.130332461 +0100 @@ -64,6 +64,7 @@ along with GCC; see the file COPYING3. #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, rt 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 (); --- gcc/testsuite/gcc.dg/asan/pr107317.c.jj 2022-11-23 17:46:09.145219960 +0100 +++ gcc/testsuite/gcc.dg/asan/pr107317.c 2022-11-23 17:49:45.148024097 +0100 @@ -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); +}