From patchwork Fri Oct 8 04:31:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Huang X-Patchwork-Id: 45985 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 37B323858428 for ; Fri, 8 Oct 2021 04:31:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 37B323858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1633667514; bh=+zIpaTkp1DF6My5m8rnMFFT69e9+yekddeukOEnWGPo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=GwQ670b/LxKHFW71nwZOC+qs6hFY+avQ1OhbwPRO6b/YS5Pix4P3Fv5JULmtl4e9m /wQ59k6MWTPc4rrHR+TJkiUTDdDSKWwaKvvJTkksqGJDKuXccKn7UuieZu9mwEnkbW Z88OVU8VuQfDN4vm3lIzee6gqXi3UW/eAJH4Ty3w= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by sourceware.org (Postfix) with ESMTPS id 513143858C2C for ; Fri, 8 Oct 2021 04:31:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 513143858C2C Received: by mail-qv1-xf2f.google.com with SMTP id 11so5616032qvd.11 for ; Thu, 07 Oct 2021 21:31:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+zIpaTkp1DF6My5m8rnMFFT69e9+yekddeukOEnWGPo=; b=BbovZrAH97PnVowye8stkX8Ix5uCv5Ty7jnI1pSlqczOlkWYpVo0qDOvEldBXz5uzC sR6faRPaWtI/f+3zkWi3Z57o6om4tFF2dSKDQFZ40LZTVAap2zEqFl9NSXOHgLclmBkA /6ENVqRdripUgobXjGixS1j2YKEaGA9lDKZ4ypgA3VnIS7zivhg1aXh2SS2nA5UvnE5N G/JnOS/q4zmld46b1Krs0oAQWnBamrQrcIpA1t3yQ/qZ/S8vA7AvZLgJOCjit+yPj1kq DrT0K5CHlvaq8O6lWdWSbHmWeL8ZN4kCtbqmFXehFd5yPmvA5yFrSVzaJPuZUedZ0fzl YOcQ== X-Gm-Message-State: AOAM532zAk+U0hI0lzF0bQAwBlOJhpP6TiaAHbQ/8VoWHWOoisA1g5I5 dxjPVDzt2iNoVr4ppPIYRZ8z2T+PW3ko0HUw X-Google-Smtp-Source: ABdhPJyf8Z7LCTwLc0FqIhKpwaeemeCpWfYLIiTE8FXOK0y01f6C5zkukL2G6Cx1HsWfZxdUTI1oKQ== X-Received: by 2002:a0c:c610:: with SMTP id v16mr7792675qvi.36.1633667484604; Thu, 07 Oct 2021 21:31:24 -0700 (PDT) Received: from localhost.localdomain (bras-base-mtrlpq4613w-grc-49-74-14-170-17.dsl.bell.ca. [74.14.170.17]) by smtp.gmail.com with ESMTPSA id k16sm1430262qta.27.2021.10.07.21.31.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 21:31:24 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Comment out announce_function to prevent ICE [PR102426] Date: Fri, 8 Oct 2021 00:31:01 -0400 Message-Id: <20211008043101.8568-1-nickhuang99@gmail.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: qingzhe huang via Gcc-patches From: Nick Huang Reply-To: qingzhe huang Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This "announce_function" is not a purely readonly function. Instead it calls tsubst which modifies global variable "current_function_decl". If it is placed at parser code directory level, recursion might happen and set/reset variable might interleave and can cause ICE. No test case is provided because this segment fault only occurs when compiler option "-quiet" is not set which is usually set by driver. That is why usual testcases cannot expose this issue. Even though this issue usually doesn't affect endusers, however, it is a headache for development. gcc/cp/ChangeLog: PR c++/102426 * decl.c (start_preparsed_function): Comment out announce_function. (emit_coro_helper): Comment out announce_function. gcc/ChangeLog: PR c++/102426 * toplev.c (get_src_pwd): Add comment to note announce_function usage. Signed-off-by: qingzhe huang --- gcc/cp/decl.c | 4 ---- gcc/toplev.c | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 2d30c790b93..94d3a2c1cba 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -16904,9 +16904,6 @@ start_preparsed_function (tree decl1, tree attrs, int flags) where store_parm_decls will find them. */ tree current_function_parms = DECL_ARGUMENTS (decl1); - /* Let the user know we're compiling this function. */ - announce_function (decl1); - gcc_assert (DECL_INITIAL (decl1)); /* This function may already have been parsed, in which case just @@ -17472,7 +17469,6 @@ emit_coro_helper (tree helper) current_function_decl = helper; begin_scope (sk_function_parms, NULL); store_parm_decls (DECL_ARGUMENTS (helper)); - announce_function (helper); allocate_struct_function (helper, false); cfun->language = ggc_cleared_alloc (); poplevel (1, 0, 1); diff --git a/gcc/toplev.c b/gcc/toplev.c index 1bb1794be96..4a3ca1aef4a 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -221,7 +221,10 @@ get_src_pwd (void) } /* Called when the start of a function definition is parsed, - this function prints on stderr the name of the function. */ + this function prints on stderr the name of the function. + NOTE: Do not use this function at directory gcc/cp level + or below because it might recurse and interleave with + function frame parsing which can cause crash. */ void announce_function (tree decl) {