public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/99798] New: ICE when compiling a variant of pr87907
@ 2021-03-27 15:59 dominiq at lps dot ens.fr
  2021-03-27 20:00 ` [Bug fortran/99798] " anlauf at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2021-03-27 15:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99798
           Summary: ICE when compiling a variant of pr87907
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dominiq at lps dot ens.fr
  Target Milestone: ---

Compiling the following variant of pr87907

module m
   interface
      module integer function g(x)
         integer, intent(in) :: x
      end
   end interface
end
submodule(m) m2
contains
   subroutine g(x)      ! { dg-error "mismatch in argument" }
     integer, intent(in) :: x
   end
end

gives

% gfc pr87907_db_2.f90
pr87907_db_2.f90:10:15:

   10 |    subroutine g(x)      ! { dg-error "mismatch in argument" }
      |               1
Error: FUNCTION attribute conflicts with SUBROUTINE attribute in 'g' at (1)
pr87907_db_2.f90:11:29:

   11 |      integer, intent(in) :: x
      |                             1
Error: Unexpected data declaration statement in CONTAINS section at (1)
f951: internal compiler error: Segmentation fault: 11

The backtrace is

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x106)
  * frame #0: 0x00000001000ec2b9 f951`gfc_free_statements(p=0x00000000000000f6)
at st.c:295:9
    frame #1: 0x00000001000f53f7 f951`gfc_free_namespace(ns=0x000000014500be00)
at symbol.c:4039:23
    frame #2: 0x00000001000f5a29 f951`gfc_free_symbol(gfc_symbol*) at
symbol.c:4037:3
    frame #3: 0x00000001000f59fc f951`gfc_free_symbol(sym=0x0000000142f0ba50)
    frame #4: 0x00000001000f53b2
f951`::free_sym_tree(sym_tree=0x0000000142f0ba20) at symbol.c:3902:22
    frame #5: 0x00000001000f5400 f951`gfc_free_namespace(ns=0x000000014500a200)
at symbol.c:4041:17
    frame #6: 0x00000001000f7034 f951`gfc_symbol_done_2() at symbol.c:4037:3
    frame #7: 0x00000001000f7016 f951`gfc_symbol_done_2()
    frame #8: 0x0000000100084689 f951`gfc_done_2() at misc.c:380:21
    frame #9: 0x00000001000a422a
f951`::clean_up_modules(gsym=0x0000000142f0b600) at parse.c:6311:14
    frame #10: 0x00000001000b2e17 f951`gfc_parse_file() at parse.c:6374:20
    frame #11: 0x000000010010d987 f951`::gfc_be_parse_file() at
f95-lang.c:212:18
    frame #12: 0x0000000100d1a294 f951`::compile_file() at toplev.c:457:25
    frame #13: 0x000000010120dd9f f951`toplev::main(int, char**) at
toplev.c:2201:24
    frame #14: 0x000000010120da5e f951`toplev::main(this=0x00007ffeefbff09e,
argc=<unavailable>, argv=<unavailable>)
    frame #15: 0x000000010120ffb1 f951`main(argc=2, argv=0x00007ffeefbff0d0) at
main.c:39:22
    frame #16: 0x00007fff2066d621 libdyld.dylib`start + 1

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

* [Bug fortran/99798] ICE when compiling a variant of pr87907
  2021-03-27 15:59 [Bug fortran/99798] New: ICE when compiling a variant of pr87907 dominiq at lps dot ens.fr
@ 2021-03-27 20:00 ` anlauf at gcc dot gnu.org
  2023-05-28  5:11 ` kargl at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-03-27 20:00 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
           Keywords|                            |ice-on-invalid-code
   Last reconfirmed|                            |2021-03-27
             Status|UNCONFIRMED                 |NEW

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

* [Bug fortran/99798] ICE when compiling a variant of pr87907
  2021-03-27 15:59 [Bug fortran/99798] New: ICE when compiling a variant of pr87907 dominiq at lps dot ens.fr
  2021-03-27 20:00 ` [Bug fortran/99798] " anlauf at gcc dot gnu.org
@ 2023-05-28  5:11 ` kargl at gcc dot gnu.org
  2023-07-11 14:56 ` mikael at gcc dot gnu.org
  2024-05-11 11:27 ` mikael at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: kargl at gcc dot gnu.org @ 2023-05-28  5:11 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org
           Priority|P3                          |P4

--- Comment #1 from kargl at gcc dot gnu.org ---
This patch prevents the ICE.  Instead of asserting that the namespace is ready
to be freed, simply return if the reference count appears to be bogus and
gfortran has already issued one or more errors.

diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc
index 221165d6dac..8e48cbba2ca 100644
--- a/gcc/fortran/symbol.cc
+++ b/gcc/fortran/symbol.cc
@@ -27,7 +27,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "parse.h"
 #include "match.h"
 #include "constructor.h"
-
+#include "diagnostic.h"  /* Access to errorcount in gfc_free_namespace ().  */

 /* Strings for all symbol attributes.  We use these for dumping the
    parse tree, in error messages, and also when reading and writing
@@ -4043,7 +4043,7 @@ gfc_free_namespace (gfc_namespace *&ns)
     return;

   ns->refs--;
-  if (ns->refs > 0)
+  if (ns->refs > 0 || (ns->refs < 0 && errorcount > 0))
     return;

   gcc_assert (ns->refs == 0);

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

* [Bug fortran/99798] ICE when compiling a variant of pr87907
  2021-03-27 15:59 [Bug fortran/99798] New: ICE when compiling a variant of pr87907 dominiq at lps dot ens.fr
  2021-03-27 20:00 ` [Bug fortran/99798] " anlauf at gcc dot gnu.org
  2023-05-28  5:11 ` kargl at gcc dot gnu.org
@ 2023-07-11 14:56 ` mikael at gcc dot gnu.org
  2024-05-11 11:27 ` mikael at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mikael at gcc dot gnu.org @ 2023-07-11 14:56 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Mikael Morin <mikael at gcc dot gnu.org> ---
Created attachment 55524
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55524&action=edit
Draft patch

I haven't completely nailed it down, but it seems that the reason for this is
the obscure condition in gfc_release_symbol to break cycles.
It triggers on the symbol for g imported from the module.  The symbol has 2
references,
one for the submodule namespace holding it, one for subroutine namespace that
is being freed.

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

* [Bug fortran/99798] ICE when compiling a variant of pr87907
  2021-03-27 15:59 [Bug fortran/99798] New: ICE when compiling a variant of pr87907 dominiq at lps dot ens.fr
                   ` (2 preceding siblings ...)
  2023-07-11 14:56 ` mikael at gcc dot gnu.org
@ 2024-05-11 11:27 ` mikael at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mikael at gcc dot gnu.org @ 2024-05-11 11:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |mikael at gcc dot gnu.org

--- Comment #3 from Mikael Morin <mikael at gcc dot gnu.org> ---
I'm working on it.

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

end of thread, other threads:[~2024-05-11 11:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-27 15:59 [Bug fortran/99798] New: ICE when compiling a variant of pr87907 dominiq at lps dot ens.fr
2021-03-27 20:00 ` [Bug fortran/99798] " anlauf at gcc dot gnu.org
2023-05-28  5:11 ` kargl at gcc dot gnu.org
2023-07-11 14:56 ` mikael at gcc dot gnu.org
2024-05-11 11:27 ` 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).