public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Steve Kargl <sgk@troutmask.apl.washington.edu>
To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] fortran/67758 -- Prevent ICE caused by misplaced COMMON
Date: Thu, 01 Oct 2015 00:07:00 -0000	[thread overview]
Message-ID: <20151001000740.GC73614@troutmask.apl.washington.edu> (raw)
In-Reply-To: <20151001000630.GB73614@troutmask.apl.washington.edu>

[-- Attachment #1: Type: text/plain, Size: 553 bytes --]

On Wed, Sep 30, 2015 at 05:06:30PM -0700, Steve Kargl wrote:
> Patch built and regression tested on x86_64-*-freebsd.
> OK to commit?
> 
> The patch prevents the dereferencing of a NULL pointer
> by jumping out of the cleanup of a list of COMMON blocks.
> 
> 2015-09-30  Steven G. Kargl  <kargl@gcc.gnu.org>
> 
> 	* symbol.c (gfc_restore_last_undo_checkpoint): Prevent ICE during
> 	cleanup of a misplaced COMMON.
> 
> 2015-09-30  Steven G. Kargl  <kargl@gcc.gnu.org>
> 
> 	* gfortran.dg/pr67758.f: New test.
> 

Now with the patch attached!

-- 
Steve

[-- Attachment #2: pr67758.diff --]
[-- Type: text/x-diff, Size: 1022 bytes --]

Index: fortran/symbol.c
===================================================================
--- fortran/symbol.c	(revision 228306)
+++ fortran/symbol.c	(working copy)
@@ -3211,6 +3211,11 @@ gfc_restore_last_undo_checkpoint (void)
 
 	      while (csym != p)
 		{
+		  if (!csym)
+		    {
+		      gfc_error ("Unexpected COMMON at %C");
+		      goto error;
+		    }
 		  cparent = csym;
 		  csym = csym->common_next;
 		}
@@ -3237,6 +3242,8 @@ gfc_restore_last_undo_checkpoint (void)
 	restore_old_symbol (p);
     }
 
+error:
+
   latest_undo_chgset->syms.truncate (0);
   latest_undo_chgset->tbps.truncate (0);
 
Index: testsuite/gfortran.dg/pr67758.f
===================================================================
--- testsuite/gfortran.dg/pr67758.f	(revision 0)
+++ testsuite/gfortran.dg/pr67758.f	(working copy)
@@ -0,0 +1,6 @@
+c { dg-do compile }
+c PR fortran/67758
+      COMMON /FMCOM / X(80 000 000)
+      CALL T(XX(A))
+      COMMON /FMCOM / XX(80 000 000) ! { dg-error "Unexpected COMMON" }
+      END

  reply	other threads:[~2015-10-01  0:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-01  0:06 Steve Kargl
2015-10-01  0:07 ` Steve Kargl [this message]
2015-10-01 12:16   ` Mikael Morin
2015-10-01 13:29     ` Mikael Morin
2015-10-01 16:30       ` Steve Kargl
2015-10-02  9:28         ` Mikael Morin
2015-10-02 16:44           ` Steve Kargl
2015-10-03 10:13             ` Mikael Morin
2015-10-03 19:09               ` Steve Kargl

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=20151001000740.GC73614@troutmask.apl.washington.edu \
    --to=sgk@troutmask.apl.washington.edu \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@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: link
Be 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).