public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/59746] New: internal compiler error: Segmentation fault
@ 2014-01-10  3:17 hjl.tools at gmail dot com
  2014-01-10  7:27 ` [Bug fortran/59746] " dominiq at lps dot ens.fr
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: hjl.tools at gmail dot com @ 2014-01-10  3:17 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59746

            Bug ID: 59746
           Summary: internal compiler error: Segmentation fault
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com

[hjl@gnu-6 gcc]$ cat testcase-min.f
         CALL RCCFL(NVE,IR,NU3,VE(1,1,1,I))
      COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL
      COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL
[hjl@gnu-6 gcc]$ ./xgcc -B./ -S -O3 -ffast-math -funroll-loops -ffixed-form 
testcase-min.f
testcase-min.f:2.72:

      COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL        
                                                                        1
Error: Unexpected COMMON statement at (1)
testcase-min.f:3.72:

      COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL        
                                                                        1
Error: Unexpected COMMON statement at (1)
f951: internal compiler error: Segmentation fault
0xbbb91a crash_signal
    /export/gnu/import/git/gcc/gcc/toplev.c:337
0x65c7a5 gfc_restore_last_undo_checkpoint()
    /export/gnu/import/git/gcc/gcc/fortran/symbol.c:3106
0x65c92d gfc_undo_symbols()
    /export/gnu/import/git/gcc/gcc/fortran/symbol.c:3156
0x6162d3 reject_statement
    /export/gnu/import/git/gcc/gcc/fortran/parse.c:1752
0x61630b unexpected_statement
    /export/gnu/import/git/gcc/gcc/fortran/parse.c:1766
0x619a06 parse_progunit
    /export/gnu/import/git/gcc/gcc/fortran/parse.c:4195
0x61a7e0 gfc_parse_file()
    /export/gnu/import/git/gcc/gcc/fortran/parse.c:4664
0x6673a2 gfc_be_parse_file
    /export/gnu/import/git/gcc/gcc/fortran/f95-lang.c:188
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
[hjl@gnu-6 gcc]$


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/59746] internal compiler error: Segmentation fault
  2014-01-10  3:17 [Bug fortran/59746] New: internal compiler error: Segmentation fault hjl.tools at gmail dot com
@ 2014-01-10  7:27 ` dominiq at lps dot ens.fr
  2014-03-03 14:17 ` bdavis at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-01-10  7:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59746

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |error-recovery
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-01-10
     Ever confirmed|0                           |1
      Known to fail|                            |4.7.4, 4.8.2, 4.9.0

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed on 4.7.4, 4.8.2, and trunk.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/59746] internal compiler error: Segmentation fault
  2014-01-10  3:17 [Bug fortran/59746] New: internal compiler error: Segmentation fault hjl.tools at gmail dot com
  2014-01-10  7:27 ` [Bug fortran/59746] " dominiq at lps dot ens.fr
@ 2014-03-03 14:17 ` bdavis at gcc dot gnu.org
  2014-03-07 12:08 ` bdavis at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bdavis at gcc dot gnu.org @ 2014-03-03 14:17 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59746

Bud Davis <bdavis at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bdavis at gcc dot gnu.org

--- Comment #2 from Bud Davis <bdavis at gcc dot gnu.org> ---
it looks like what was happening was the variable that was previously defined,
NVE, was not getting deleted out of the common block by
restore_last_undo_checkpoint.  Then the next time it was called, the common
block list was messed up.

The code would only remove a variable from a common block if it was just
defined in the previous statement.  I changed it so it would remove a variable
from a common block if it was just defined, or if it previously existed and was
put in the common block in the last statement.

This patch works with the example given and has no regressions in the
testsuite.

Short on time, wanted to save this info so it is not lost.  If anyone wants to
finish this up (testcase, blah. blah...) please feel free to do so.

--bud davis



[bdavis@budlinux1 current]$ svn diff gcc
Index: gcc/gcc/fortran/symbol.c
===================================================================
--- gcc/gcc/fortran/symbol.c    (revision 208254)
+++ gcc/gcc/fortran/symbol.c    (working copy)
@@ -3069,9 +3069,10 @@

   FOR_EACH_VEC_ELT (latest_undo_chgset->syms, i, p)
     {
-      if (p->gfc_new)
+      if (p->gfc_new || (p->old_symbol && !p->old_symbol->common_block))
     {
-      /* Symbol was new.  */
+      /* Symbol was new. Or it is old, and was just put in a common
+             block  */
       if (p->attr.in_common && p->common_block && p->common_block->head)
         {
           /* If the symbol was added to any common block, it
@@ -3092,7 +3093,9 @@
         }

           if (p->common_block->head == p)
+              {
             p->common_block->head = p->common_next;
+              }
           else
         {
           gfc_symbol *cparent, *csym;
@@ -3107,25 +3110,29 @@
             }

           gcc_assert(cparent->common_next == p);
-
           cparent->common_next = csym->common_next;
         }
         }
+        }
+        if (p->gfc_new)
+          {

-      /* The derived type is saved in the symtree with the first
-         letter capitalized; the all lower-case version to the
-         derived type contains its associated generic function.  */
-      if (p->attr.flavor == FL_DERIVED)
-        gfc_delete_symtree (&p->ns->sym_root, gfc_get_string ("%c%s",
-                        (char) TOUPPER ((unsigned char) p->name[0]),
-                        &p->name[1]));
-      else
-        gfc_delete_symtree (&p->ns->sym_root, p->name);
+        /* The derived type is saved in the symtree with the first
+           letter capitalized; the all lower-case version to the
+           derived type contains its associated generic function.  */
+        if (p->attr.flavor == FL_DERIVED)
+          gfc_delete_symtree (&p->ns->sym_root, gfc_get_string ("%c%s",
+                                  (char) TOUPPER ((unsigned char) p->name[0]),
+                                  &p->name[1]));
+        else
+          gfc_delete_symtree (&p->ns->sym_root, p->name);

-      gfc_release_symbol (p);
-    }
-      else
-    restore_old_symbol (p);
+        gfc_release_symbol (p);
+      }
+        else
+          {
+            restore_old_symbol (p);
+          }
     }

   latest_undo_chgset->syms.truncate (0);


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/59746] internal compiler error: Segmentation fault
  2014-01-10  3:17 [Bug fortran/59746] New: internal compiler error: Segmentation fault hjl.tools at gmail dot com
  2014-01-10  7:27 ` [Bug fortran/59746] " dominiq at lps dot ens.fr
  2014-03-03 14:17 ` bdavis at gcc dot gnu.org
@ 2014-03-07 12:08 ` bdavis at gcc dot gnu.org
  2014-10-12  6:44 ` fxcoudert at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bdavis at gcc dot gnu.org @ 2014-03-07 12:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59746

--- Comment #3 from Bud Davis <bdavis at gcc dot gnu.org> ---
Not so fast...

Made a test for it:
!pr59746
      CALL RCCFL(NVE,IR,NU3,VE(1,1,1,I))
      COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL
      COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL
!  the PR only contained the two above.
!  success is no segfaults or infinite loops.  
!  let's check some combinations
     CALL ABC (INTG)
     COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL
     COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL
     CALL DEF (NT1)
     COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL
     COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL
     CALL GHI (NRESL)
     COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL
     COMMON /CCFILE/ INTG,NT1,NT2,NT3,NVM,NVE,NFRLE,NRESF,NRESL
      END

And all the 'extras' also cause a segfault.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/59746] internal compiler error: Segmentation fault
  2014-01-10  3:17 [Bug fortran/59746] New: internal compiler error: Segmentation fault hjl.tools at gmail dot com
                   ` (2 preceding siblings ...)
  2014-03-07 12:08 ` bdavis at gcc dot gnu.org
@ 2014-10-12  6:44 ` fxcoudert at gcc dot gnu.org
  2015-08-08 10:40 ` mikael at gcc dot gnu.org
  2015-08-08 10:42 ` mikael at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2014-10-12  6:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59746

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fxcoudert at gcc dot gnu.org

--- Comment #5 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Hey Bud, I suppose it is time to apply this patch, isn't it? We're in stage 1
for a few more weeks.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/59746] internal compiler error: Segmentation fault
  2014-01-10  3:17 [Bug fortran/59746] New: internal compiler error: Segmentation fault hjl.tools at gmail dot com
                   ` (3 preceding siblings ...)
  2014-10-12  6:44 ` fxcoudert at gcc dot gnu.org
@ 2015-08-08 10:40 ` mikael at gcc dot gnu.org
  2015-08-08 10:42 ` mikael at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-08-08 10:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59746

--- Comment #6 from Mikael Morin <mikael at gcc dot gnu.org> ---
Author: mikael
Date: Sat Aug  8 10:40:06 2015
New Revision: 226732

URL: https://gcc.gnu.org/viewcvs?rev=226732&root=gcc&view=rev
Log:
When undoing symbols, also restore common block lists

gcc/fortran/
2015-08-08  Bud Davis  <jmdavis@link.com>
            Mikael Morin  <mikael@gcc.gnu.org>

        PR fortran/59746
        * symbol.c (gfc_restore_last_undo_checkpoint): Delete a common block
        symbol if it was put in the list.

gcc/testsuite/
2015-08-08  Bud Davis  <jmdavis@link.com>

        PR fortran/59746
        * gfortran.dg/common_22.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/common_22.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/symbol.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/59746] internal compiler error: Segmentation fault
  2014-01-10  3:17 [Bug fortran/59746] New: internal compiler error: Segmentation fault hjl.tools at gmail dot com
                   ` (4 preceding siblings ...)
  2015-08-08 10:40 ` mikael at gcc dot gnu.org
@ 2015-08-08 10:42 ` mikael at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-08-08 10:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59746

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |mikael at gcc dot gnu.org
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |mikael at gcc dot gnu.org

--- Comment #7 from Mikael Morin <mikael at gcc dot gnu.org> ---
Fixed for 6.0, closing.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-08-08 10:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-10  3:17 [Bug fortran/59746] New: internal compiler error: Segmentation fault hjl.tools at gmail dot com
2014-01-10  7:27 ` [Bug fortran/59746] " dominiq at lps dot ens.fr
2014-03-03 14:17 ` bdavis at gcc dot gnu.org
2014-03-07 12:08 ` bdavis at gcc dot gnu.org
2014-10-12  6:44 ` fxcoudert at gcc dot gnu.org
2015-08-08 10:40 ` mikael at gcc dot gnu.org
2015-08-08 10:42 ` mikael at gcc dot gnu.org

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).