Bug 78983 - [7/8/9 Regression] ICE with CAF-DT with allocatable member
Summary: [7/8/9 Regression] ICE with CAF-DT with allocatable member
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 7.0
: P4 normal
Target Milestone: 7.5
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: Coarray
  Show dependency treegraph
 
Reported: 2017-01-04 07:40 UTC by Stefano Zaghi
Modified: 2019-02-13 12:14 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-01-05 00:00:00


Attachments
MCVE of CAF-DT with allocatable member (665 bytes, text/plain)
2017-01-04 07:40 UTC, Stefano Zaghi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stefano Zaghi 2017-01-04 07:40:53 UTC
Created attachment 40450 [details]
MCVE of CAF-DT with allocatable member

My current "env" is

+ GNU Fortran (GCC) 7.0.0 20161206 (experimental)
+ MPICH 3.2.0 built with GCC 7.0.0
+ OpenCoarrays built 1.7.5 with GCC 7.0.0 and MPICH 3.2.0
+ Linux 4.8.8-2-ARCH #1 SMP PREEMPT Thu Nov 17 14:51:03 CET 2016 x86_64 GNU/Linux

The MCVE raising the ICE is attached as "MCVE of CAF-DT with allocatable member". Essentially, there is a "base" DT (named "node") with an allocatable member, a second DT (named "caf") that has a coarray member of "type(node)". The last concrete instance of "type(caf)" is a scalar, static variable thus the code should be valid (while I still think that the other is invalid). 

Compiling this code with the above env generates the following ICE

stefano@zaghi(09:38 AM Mon Dec 12) desk {opencoarrays-1.7.5-gnu-7.0.0 - OpenCoarrays 1.7.5 with gcc 7.0.0 environment}
~/fortran/compilers_bug/gfortran_sigsegv_caf_dt_allocatable_member 5 files, 84Kb
→ caf -fcoarray=lib sigsegv_caf_dt.f90
sigsegv_caf_dt.f90:77:0:

 end module caf_module
 
internal compiler error: Segmentation fault
0xc0db4f crash_signal
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/toplev.c:333
0xeb1764 recompute_tree_invariant_for_addr_expr(tree_node*)
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/tree.c:4317
0xeb1d7c build1_stat(tree_code, tree_node*, tree_node*)
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/tree.c:4414
0x92c76c build1_stat_loc
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/tree.h:3903
0x92c76c fold_build1_stat_loc(unsigned int, tree_code, tree_node*, tree_node*)
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/fold-const.c:12139
0x6f204f gfc_build_addr_expr(tree_node*, tree_node*)
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/fortran/trans.c:298
0x70532b structure_alloc_comps
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/fortran/trans-array.c:8329
0x7827b3 gfc_trans_deallocate(gfc_code*)
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/fortran/trans-stmt.c:6477
0x6f1bf7 trans_code
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/fortran/trans.c:1942
0x7742f3 gfc_trans_if_1
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/fortran/trans-stmt.c:1303
0x77c39a gfc_trans_if(gfc_code*)
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/fortran/trans-stmt.c:1334
0x6f1ce7 trans_code
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/fortran/trans.c:1878
0x7742f3 gfc_trans_if_1
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/fortran/trans-stmt.c:1303
0x77c39a gfc_trans_if(gfc_code*)
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/fortran/trans-stmt.c:1334
0x6f1ce7 trans_code
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/fortran/trans.c:1878
0x77e271 gfc_trans_simple_do
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/fortran/trans-stmt.c:1924
0x77e271 gfc_trans_do(gfc_code*, tree_node*)
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/fortran/trans-stmt.c:2057
0x6f1cba trans_code
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/fortran/trans.c:1890
0x723038 gfc_generate_function_code(gfc_namespace*)
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/fortran/trans-decl.c:6271
0x6f6949 gfc_generate_module_code(gfc_namespace*)
        /opt/arch/gcc/opencoarrays/prerequisites/downloads/trunk/gcc/fortran/trans.c:2164
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.

My best regards.
Comment 1 Dominique d'Humieres 2017-01-05 15:29:30 UTC
The code compiles with revision r242984 (2016-11-29), but gives an ICE with r243219, likely r243021. Note the code compiles with -fcoarray=single.
Comment 2 Andre Vehreschild 2017-01-13 12:22:45 UTC
Well, this issue more difficult than it looks. I do not presume a solution will be ready for gcc 7.0. So I do not expect to hold the target milestone.
Comment 3 Damian Rouson 2017-01-17 19:43:03 UTC
Here's a simpler demonstration of two problems this bug report identifies:

module node_module
  implicit none
  type node
    integer, allocatable :: storage
  end type
contains
  subroutine reallocate_node_storage(some_node)
    type(node) :: some_node
    allocate(some_node%storage)  ! needs to generate a call to caf_register
  end subroutine
end module

module caf_module
  use node_module
  type caf
    type(node), allocatable :: array[:]
  end type
contains
  subroutine allocate_storage(this)
    class(caf) :: this
    allocate(this%array[*]) !ICE: no token member initialized for node storage
    call reallocate_node_storage(this%array)
  end subroutine
end module
Comment 4 Jakub Jelinek 2017-05-02 15:58:13 UTC
GCC 7.1 has been released.
Comment 5 Dominique d'Humieres 2017-12-27 12:55:00 UTC
AFAICT this PR is fixed by the patch at https://gcc.gnu.org/ml/fortran/2017-12/msg00099.html.
Comment 6 Damian Rouson 2017-12-29 04:49:10 UTC
Using 7.2, I still see an ICE with the reduced example from Comment 3:

$ gfortran -fcoarray=lib -c bug-78983.f90 
bug-78983.f90:24:0:

 end module
 
internal compiler error: in gfc_conv_descriptor_data_get, at fortran/trans-array.c:144
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
Comment 7 Dominique d'Humieres 2017-12-30 14:58:18 UTC
> Using 7.2, I still see an ICE with the reduced example from Comment 3:

You didn't apply Paul's patch at https://gcc.gnu.org/ml/fortran/2017-12/msg00099.html, did you? So why are you surprised that the PR isn't fixed?

> AFAICT this PR is fixed by the patch at
> https://gcc.gnu.org/ml/fortran/2017-12/msg00099.html.

Tested on trunk (8.0) only.
Comment 8 Richard Biener 2018-01-25 08:23:01 UTC
GCC 7.3 is being released, adjusting target milestone.
Comment 9 Jürgen Reuter 2018-10-19 15:34:33 UTC
This reads that this bug/regression has been fixed on version 8 (and therewith presumably 9), but just not backported to version 7. Correct? 
For the actual trunk and OpenCoarrays 2.1 everything works for me (compilation and execution).
Comment 10 Damian Rouson 2019-02-13 08:14:59 UTC
I see no ICE in testing the code from Comment 3 using fortran 7.3.0, 8.2.0, and 9.0.1.  I believe this can be closed.
Comment 11 Dominique d'Humieres 2019-02-13 12:14:18 UTC
> I see no ICE in testing the code from Comment 3 using fortran 7.3.0,
> 8.2.0, and 9.0.1. 

Confirmed.

> I believe this can be closed.

Closing.