From patchwork Wed Dec 8 20:21:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1565487 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=aWkbzttt; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J8T9b0h5zz9sVq for ; Thu, 9 Dec 2021 07:22:25 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B4E05385843A for ; Wed, 8 Dec 2021 20:22:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4E05385843A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1638994941; bh=e76UZGla4UUccZeDEFML7ejkLKlbBgn4cFg6oHA/dyA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=aWkbztttSCnXOJ/BD8v4IgTLj7fmOSnGhDkqG4qwgPvfgg9UpheyVaXu8d/+B7mmO duHgTSWOzKVR3qad8O01aFbe1eD5+0muaFMAZGNTa8NFWZfjVoaF0b+8tQUuIFeqEZ tCAfxey69gdZ9to2d/kv1fknWM0y9wN7Ewp45/R0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by sourceware.org (Postfix) with ESMTPS id 1C08E3858D3C; Wed, 8 Dec 2021 20:21:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1C08E3858D3C X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [79.251.11.168] ([79.251.11.168]) by web-mail.gmx.net (3c-app-gmx-bs37.server.lan [172.19.170.89]) (via HTTP); Wed, 8 Dec 2021 21:21:21 +0100 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH, committed] PR fortran/103609 - [11/12 Regression] ICE in gfc_sym_get_dummy_args, at fortran/symbol.c:5243 Date: Wed, 8 Dec 2021 21:21:21 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:D2a5R88jX6gPCT07DdDESmMMVSq1EESD4fFeTFOPL5Fhnm0upWXk8zSCBMx1DfydVUCvl Mwlnk7eGDDf9m43rm6SiGUb38IwrKSsZoHCKjT6L0xqfbX36hqSGb+n06dmi8pRo28ks3LhefqFs gcOR46N70c5O1jdVp9vvQAk09R/Qk75OjRAEDS9mGWuxTVfsMKkS+14Q8sm/Ttizx9RgXpu/z8eN 3s39gb1msNACLHMDQFC9czv/q1IsioPmtXANwUgARa5K2ZV0ze9XQ/2qHxv2iLV3WhNHeGqVVicM 5k= X-UI-Out-Filterresults: notjunk:1;V03:K0:6UHK4mW8QJo=:lrF1qTVDKTnFKB7DGrQptq 859kA43uqjCe/poiQPsCzBCLTdizT15kkjMT449AXcGvgDzVIJ/PwAdRZ3H4DrLUrTzHWPTMC x2mI1tmMgJuuHoXQDdHZxR7evqQauJ0xYlB8q+BkvskHN5a0hSXtOSjfIiTLrQTgntoeLRjdY NHuZxVvF00Csw6Lf9OBDNKHnAm+R06+4dYTOt4bU4F+ny/eHJJUKDbrvN+YTt9nOK8qxe69n9 uv7ErVWhajJ/C6jm+EPB8P1wi5oOlbYLLeuX/mMaV7vA0qzC3GHokjH+lRoi0ZK9OO9CbNWPY mMsJCYWHVB3SZMPZ6hjYKYIsc2ggv4Kp8vl6hfSy8lwvYwePobtELd6GbdWglVOyzgbPW+WAl p3QCjSmgD/hPJcqUwYGbs+3Ibla1u/yCx/N4bumUxIgQSnB/2rbozU67SHAzWCB63hSQDSOlk HbEjv5BEFYxb8VdqrhNS1yJd3bgmtHhxjHTGptO3BuVtK/IeD34T9Em+AkkEJSQvhepZyOZ0o dJhxy5oEw2dTVkbWMYm6wAd1Hggz51VdMngymtxVTrZCZbtrk1e70LyHWrAFVCZwkp+s50oOp sxLRbqUQIRccllcdp3N/LUObAjO2zf1dqtajaR7i3Ykvx+OYzgk29Gp/chAV46jVx8ULZNrtL BqmQ4PaTCMH2DEyXjxtfgXLT1xzz+gPzVd9lpCwX1Ey2W5jUk/SNXYcxXz/Kalcwq+LkjELaa 1IGq0/2c2UeyPQcgioSxOiY4m6vAhD/kBhho+fh9Pv+KgAeYFo09R0NrjH8= X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_MSPIKE_H2, 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: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Dear all, the attached patch fixes a NULL pointer dereference for a missed declaration of a dummy argument or a conflict of a procedure with another decl. Committed as obvious after regtesting on x86_64-pc-linux-gnu: commit r12-5847-gb77968a70537429b4f548f90c369d26e6b6943cc Author: Harald Anlauf Date: Wed Dec 8 21:14:19 2021 +0100 Fortran: avoid NULL pointer dereference on missing or bad dummy arguments gcc/fortran/ChangeLog: PR fortran/103609 * symbol.c (gfc_sym_get_dummy_args): Catch NULL pointer dereference. gcc/testsuite/ChangeLog: PR fortran/103609 * gfortran.dg/pr103609.f90: New test. Thanks, Harald From b77968a70537429b4f548f90c369d26e6b6943cc Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 8 Dec 2021 21:14:19 +0100 Subject: [PATCH] Fortran: avoid NULL pointer dereference on missing or bad dummy arguments gcc/fortran/ChangeLog: PR fortran/103609 * symbol.c (gfc_sym_get_dummy_args): Catch NULL pointer dereference. gcc/testsuite/ChangeLog: PR fortran/103609 * gfortran.dg/pr103609.f90: New test. --- gcc/fortran/symbol.c | 3 +++ gcc/testsuite/gfortran.dg/pr103609.f90 | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr103609.f90 diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 179f6029ca3..ebd99846610 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -5240,6 +5240,9 @@ gfc_sym_get_dummy_args (gfc_symbol *sym) { gfc_formal_arglist *dummies; + if (sym == NULL) + return NULL; + dummies = sym->formal; if (dummies == NULL && sym->ts.interface != NULL) dummies = sym->ts.interface->formal; diff --git a/gcc/testsuite/gfortran.dg/pr103609.f90 b/gcc/testsuite/gfortran.dg/pr103609.f90 new file mode 100644 index 00000000000..57f6a3b1531 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr103609.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +! PR fortran/103609 - ICE in gfc_sym_get_dummy_args +! Contributed by G.Steinmetz + +program p + implicit none + integer :: i + do i = 1, 2 + call s + end do +contains + subroutine s + call sub(x) ! { dg-error "has no IMPLICIT type" } + end +end -- 2.26.2