public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/27269]  New: Segfault with EQUIVALENCEs in modules together with ONLY clauses
@ 2006-04-23 11:29 tobi at gcc dot gnu dot org
  2006-04-23 11:45 ` [Bug fortran/27269] " tobi at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: tobi at gcc dot gnu dot org @ 2006-04-23 11:29 UTC (permalink / raw)
  To: gcc-bugs

schluter@pcl247d:~/src/work/bug> cat t.f90
      module const
      ! Kind parameters
      integer, parameter :: dp = kind(1d0)

        double precision reimMUE(2), reMUE, imMUE
        equivalence (MUE, reimMUE)
        equivalence (reimMUE(1), reMUE), (reimMUE(2), imMUE)

      end module const

module cross_section
  use const, only: dp
end module cross_section


  use const
  use cross_section

  implicit none

end program
schluter@pcl247d:~/src/work/bug> ~/src/gcc/build/gcc/f951 t.f90
t.f90:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
schluter@pcl247d:~/src/work/bug> ~/src/gcc/build/gcc/f951 --version
GNU F95 version 4.2.0 20060421 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 4.2.0 20060421 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
schluter@pcl247d:~/src/work/bug> gdb ~/src/gcc/build/gcc/f951
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db
library "/lib/libthread_db.so.1".

(gdb) run t.f90
Starting program: /home/pcl331/schluter/src/gcc/build/gcc/f951 t.f90

Program received signal SIGSEGV, Segmentation fault.
0x0808dc3d in resolve_types (ns=0x870d288) at ../../gcc/fortran/resolve.c:5829
5829      last_ts = &eq->expr->symtree->n.sym->ts;
(gdb) bt
#0  0x0808dc3d in resolve_types (ns=0x870d288)
    at ../../gcc/fortran/resolve.c:5829
#1  0x080902bc in gfc_resolve (ns=0x870d288)
    at ../../gcc/fortran/resolve.c:6252
#2  0x08086059 in gfc_parse_file () at ../../gcc/fortran/parse.c:3179
#3  0x080a64dd in gfc_be_parse_file (set_yydebug=0)
    at ../../gcc/fortran/f95-lang.c:301
#4  0x08391fea in toplev_main (argc=2, argv=0xbffff984)
    at ../../gcc/toplev.c:999
#5  0x080d867f in main (argc=Cannot access memory at address 0x1
) at ../../gcc/main.c:35
(gdb)  p eq->expr->symtree
$2 = (gfc_symtree *) 0x0
(gdb)

For the bug to trigger both the direct and the indirect use as well as the ONLY
clause are necessary.  Note that the actual code location is in
resolve_equivalence, so the bug is probably due to gfortran trying to
understand an equivalence whose member variables have not been loaded, due to
the ONLY clause.


-- 
           Summary: Segfault with EQUIVALENCEs in modules together with ONLY
                    clauses
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tobi at gcc dot gnu dot org


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


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

* [Bug fortran/27269] Segfault with EQUIVALENCEs in modules together with ONLY clauses
  2006-04-23 11:29 [Bug fortran/27269] New: Segfault with EQUIVALENCEs in modules together with ONLY clauses tobi at gcc dot gnu dot org
@ 2006-04-23 11:45 ` tobi at gcc dot gnu dot org
  2006-04-26 14:09 ` paul dot thomas at jet dot uk
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: tobi at gcc dot gnu dot org @ 2006-04-23 11:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from tobi at gcc dot gnu dot org  2006-04-23 11:45 -------
Since I still have it on my screen:
(gdb) p eq->expr->where->nextc-18
$6 = 0x8708de9 " use cross_section"


-- 


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


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

* [Bug fortran/27269] Segfault with EQUIVALENCEs in modules together with ONLY clauses
  2006-04-23 11:29 [Bug fortran/27269] New: Segfault with EQUIVALENCEs in modules together with ONLY clauses tobi at gcc dot gnu dot org
  2006-04-23 11:45 ` [Bug fortran/27269] " tobi at gcc dot gnu dot org
@ 2006-04-26 14:09 ` paul dot thomas at jet dot uk
  2006-04-26 16:41 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paul dot thomas at jet dot uk @ 2006-04-26 14:09 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1836 bytes --]



------- Comment #2 from paul dot thomas at jet dot uk  2006-04-26 14:09 -------
The testcase reduces to:

module a
  integer, parameter :: dp = kind (1d0)
  real(dp) :: reM, M
  equivalence (M, reM)
end module a

module b
  use a, only : dp
end module b

  use a
  use b
  print *, M
  reM = 0.5d1
  print *, M
end

and can be fixed by ensuring that equivalences with unused module variables
never get to the namespace.  Here is a preliminary patch that accomplishes
this.  Using gfc_free_equiv causes segfaults further down the line because
eq->expr
is being freed.  I do not know, at the moment, why that should be.  To keep
memory leaks to the minimum, I have just freed the gfc_equiv, for the time
being.  Working on this has exposed another, in some ways more serious, bug,
which I will add to the database.

Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c        (r?®vision 113192)
+++ gcc/fortran/module.c        (copie de travail)
@@ -3013,7 +3022,8 @@
 static void
 load_equiv(void)
 {
-  gfc_equiv *head, *tail, *end;
+  gfc_equiv *head, *tail, *end, *eq;
+  bool unused;

   mio_lparen();

@@ -3039,12 +3049,33 @@
        mio_expr(&tail->expr);
       }

+    unused = false;
+    for (eq = head; eq; eq = eq->eq)
+      {
+       if (!(eq && eq->expr && eq->expr->symtree))
+         {
+           unused = true;
+           break;
+         }
+      }
+
+    if (unused)
+      {
+       for (eq = head; eq; eq = head)
+         {
+           head = eq->eq;
+           gfc_free (eq);
+         }
+      }
+
     if (end == NULL)
       gfc_current_ns->equiv = head;
     else
       end->next = head;

-    end = head;
+    if (head != NULL)
+      end = head;
+
     mio_rparen();
   }


-- 


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


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

* [Bug fortran/27269] Segfault with EQUIVALENCEs in modules together with ONLY clauses
  2006-04-23 11:29 [Bug fortran/27269] New: Segfault with EQUIVALENCEs in modules together with ONLY clauses tobi at gcc dot gnu dot org
  2006-04-23 11:45 ` [Bug fortran/27269] " tobi at gcc dot gnu dot org
  2006-04-26 14:09 ` paul dot thomas at jet dot uk
@ 2006-04-26 16:41 ` pinskia at gcc dot gnu dot org
  2006-04-28  9:15 ` patchapp at dberlin dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-04-26 16:41 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-04-26 16:41:05
               date|                            |


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


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

* [Bug fortran/27269] Segfault with EQUIVALENCEs in modules together with ONLY clauses
  2006-04-23 11:29 [Bug fortran/27269] New: Segfault with EQUIVALENCEs in modules together with ONLY clauses tobi at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-04-26 16:41 ` pinskia at gcc dot gnu dot org
@ 2006-04-28  9:15 ` patchapp at dberlin dot org
  2006-05-02 14:13 ` sayle at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: patchapp at dberlin dot org @ 2006-04-28  9:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from patchapp at dberlin dot org  2006-04-28 09:15 -------
Subject: Bug number PR27269

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2006-04/msg01079.html


-- 


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


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

* [Bug fortran/27269] Segfault with EQUIVALENCEs in modules together with ONLY clauses
  2006-04-23 11:29 [Bug fortran/27269] New: Segfault with EQUIVALENCEs in modules together with ONLY clauses tobi at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-04-28  9:15 ` patchapp at dberlin dot org
@ 2006-05-02 14:13 ` sayle at gcc dot gnu dot org
  2006-05-02 14:24 ` roger at eyesopen dot com
  2006-05-08  5:02 ` pault at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: sayle at gcc dot gnu dot org @ 2006-05-02 14:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from sayle at gcc dot gnu dot org  2006-05-02 14:13 -------
Subject: Bug 27269

Author: sayle
Date: Tue May  2 14:13:17 2006
New Revision: 113465

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113465
Log:
2006-05-02 Paul Thomas <pault@gcc.gnu.org>

        PR fortran/27269
        * module.c: Add static flag in_load_equiv.
        (mio_expr_ref): Return if no symtree and in_load_equiv.
        (load_equiv): If any of the equivalence members have no symtree, free
        the equivalence and the associated expressions.

        PR fortran/27324
        * trans-common.c (gfc_trans_common): Invert the order of calls to
        finish equivalences and gfc_commit_symbols.

        PR fortran/27269
        PR fortran/27324
        * gfortran.dg/module_equivalence_2.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/module_equivalence_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/module.c
    trunk/gcc/fortran/trans-common.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/27269] Segfault with EQUIVALENCEs in modules together with ONLY clauses
  2006-04-23 11:29 [Bug fortran/27269] New: Segfault with EQUIVALENCEs in modules together with ONLY clauses tobi at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-05-02 14:13 ` sayle at gcc dot gnu dot org
@ 2006-05-02 14:24 ` roger at eyesopen dot com
  2006-05-08  5:02 ` pault at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: roger at eyesopen dot com @ 2006-05-02 14:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from roger at eyesopen dot com  2006-05-02 14:24 -------
This should now be fixed on mainline, thanks to Paul's patch.


-- 

roger at eyesopen dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.2.0


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


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

* [Bug fortran/27269] Segfault with EQUIVALENCEs in modules together with ONLY clauses
  2006-04-23 11:29 [Bug fortran/27269] New: Segfault with EQUIVALENCEs in modules together with ONLY clauses tobi at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-05-02 14:24 ` roger at eyesopen dot com
@ 2006-05-08  5:02 ` pault at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2006-05-08  5:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pault at gcc dot gnu dot org  2006-05-08 05:02 -------
Subject: Bug 27269

Author: pault
Date: Mon May  8 05:01:56 2006
New Revision: 113618

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113618
Log:
2006-05-08  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/24813
        * trans-array.c (get_array_ctor_strlen): Remove static attribute.
        * trans.h: Add prototype for get_array_ctor_strlen.
        * trans-intrinsic.c (gfc_conv_intrinsic_len): Switch on EXPR_ARRAY
        and call get_array_ctor_strlen.

        PR fortran/27269
        * module.c: Add static flag in_load_equiv.
        (mio_expr_ref): Return if no symtree and in_load_equiv.
        (load_equiv): If any of the equivalence members have no symtree, free
        the equivalence and the associated expressions.

        PR fortran/27324
        * trans-common.c (gfc_trans_common): Invert the order of calls to
        finish equivalences and gfc_commit_symbols.

        PR fortran/25099
        * resolve.c (resolve_call): Check conformity of elemental
        subroutine actual arguments.

2006-05-08  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/24813
        * gfortran.dg/char_cons_len.f90: New test.

        PR fortran/27269
        PR fortran/27324
        * gfortran.dg/module_equivalence_2.f90: New test.

        PR fortran/25099
        * gfortran.dg/elemental_subroutine_4.f90: New test.
        * gfortran.dg/assumed_size_refs_1.f90: Add error to non-conforming
        call sub (m, x).



Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/char_cons_len.f90
   
branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/elemental_subroutine_4.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/module_equivalence_2.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/module.c
    branches/gcc-4_1-branch/gcc/fortran/resolve.c
    branches/gcc-4_1-branch/gcc/fortran/trans-array.c
    branches/gcc-4_1-branch/gcc/fortran/trans-common.c
    branches/gcc-4_1-branch/gcc/fortran/trans-intrinsic.c
    branches/gcc-4_1-branch/gcc/fortran/trans.h
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/assumed_size_refs_1.f90


-- 


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


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

end of thread, other threads:[~2006-05-08  5:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-23 11:29 [Bug fortran/27269] New: Segfault with EQUIVALENCEs in modules together with ONLY clauses tobi at gcc dot gnu dot org
2006-04-23 11:45 ` [Bug fortran/27269] " tobi at gcc dot gnu dot org
2006-04-26 14:09 ` paul dot thomas at jet dot uk
2006-04-26 16:41 ` pinskia at gcc dot gnu dot org
2006-04-28  9:15 ` patchapp at dberlin dot org
2006-05-02 14:13 ` sayle at gcc dot gnu dot org
2006-05-02 14:24 ` roger at eyesopen dot com
2006-05-08  5:02 ` pault at gcc dot gnu dot 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).