public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/65841] New: Seg fault on intrinsic assignment to allocatable derived type with allocatable component
@ 2015-04-22  0:43 damian at sourceryinstitute dot org
  2015-04-22 13:03 ` [Bug fortran/65841] " pault at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: damian at sourceryinstitute dot org @ 2015-04-22  0:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65841
           Summary: Seg fault on intrinsic assignment to allocatable
                    derived type with allocatable component
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: damian at sourceryinstitute dot org

The code below produces a segmentation fault upon the second intrinsic
assignment to an allocatable component of derived type containing an
allocatable component of intrinsic type.

Damian

$ cat realloc_alloc_comp_with_alloc_comp.f90 
type a
  real, allocatable :: f
end type
type b
  type(a), allocatable :: g
end type
type(b) c,d
c%g=a(1.) 
d=c       
d=c       ! seg fault with gfortran 5.0 Build 20150216
end

$ gfortran realloc_alloc_comp_with_alloc_comp.f90 

$ ./a.out

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7F3705ACEBB7
#1  0x7F3705ACDDB0
#2  0x7F3704FD949F
#3  0x7F370502654C
#4  0x400901 in MAIN__ at realloc_alloc_comp_with_alloc_comp.f90:0
Segmentation fault (core dumped)

$ gfortran --version
GNU Fortran (GCC) 5.0.0 20150216 (experimental)


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

* [Bug fortran/65841] Seg fault on intrinsic assignment to allocatable derived type with allocatable component
  2015-04-22  0:43 [Bug fortran/65841] New: Seg fault on intrinsic assignment to allocatable derived type with allocatable component damian at sourceryinstitute dot org
@ 2015-04-22 13:03 ` pault at gcc dot gnu.org
  2015-04-22 14:24 ` dominiq at lps dot ens.fr
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu.org @ 2015-04-22 13:03 UTC (permalink / raw)
  To: gcc-bugs

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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-04-22
                 CC|                            |pault at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Paul Thomas <pault at gcc dot gnu.org> ---
Confirmed

type a
  real, allocatable :: f
end type
type b
  type(a), allocatable :: g
end type
type(b) c,d
c%g=a(1.) 
d=c
d%g%f = 2.0 ! This causes the segfault too
end

However, if I make c and d allocatable

  type a
    real, allocatable :: f
  end type
  type b
    type(a), allocatable :: g
  end type
  type(b), allocatable :: c, d ! Note allocatable now
  allocate (c)
  c%g = a (1.)
  d = c
  d = c
end


... it does not segfault. Note both must be allocatable for this to work. This
should be a clue but I still do not see what is wrong with the code produced
for the segfaulting cases. More staring at it tonight!

Thanks for the report

Paul


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

* [Bug fortran/65841] Seg fault on intrinsic assignment to allocatable derived type with allocatable component
  2015-04-22  0:43 [Bug fortran/65841] New: Seg fault on intrinsic assignment to allocatable derived type with allocatable component damian at sourceryinstitute dot org
  2015-04-22 13:03 ` [Bug fortran/65841] " pault at gcc dot gnu.org
@ 2015-04-22 14:24 ` dominiq at lps dot ens.fr
  2015-04-23  7:39 ` dominiq at lps dot ens.fr
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-04-22 14:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
I confirm the segfault with my clean trees for all variants (4.8 and 4.9 give
an ICE).

However I don't see them on my patched trees having Mikael's patch for pr65792
(https://gcc.gnu.org/ml/fortran/2015-04/msg00063.html) and Andre's one for
pr59678 (https://gcc.gnu.org/ml/fortran/2015-04/msg00061.html). Note that the
last test in comment 1 segfault with only the [fist patch] for pr65792 + the
one for pr59678.

All the test run without segfault with the cumulated patch for pr61831 and
pr65792 (https://gcc.gnu.org/bugzilla/attachment.cgi?id=35352) + the one for
pr59678.

Note also that repeated assignments is checked by
gfortran.dg/alloc_comp_assign_10.f90 (pr39879):

  u%model = u%design
  u%model = u%design ! The double assignment was the cause of the ICE


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

* [Bug fortran/65841] Seg fault on intrinsic assignment to allocatable derived type with allocatable component
  2015-04-22  0:43 [Bug fortran/65841] New: Seg fault on intrinsic assignment to allocatable derived type with allocatable component damian at sourceryinstitute dot org
  2015-04-22 13:03 ` [Bug fortran/65841] " pault at gcc dot gnu.org
  2015-04-22 14:24 ` dominiq at lps dot ens.fr
@ 2015-04-23  7:39 ` dominiq at lps dot ens.fr
  2015-04-27 17:34 ` vehre at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-04-23  7:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
This PR is fixed by Andre's patch for pr59678 (all tests).

> Note that the last test in comment 1 segfault with only the [fist patch]
> for pr65792 + the one for pr59678.

So this is another conflict between the two patches.


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

* [Bug fortran/65841] Seg fault on intrinsic assignment to allocatable derived type with allocatable component
  2015-04-22  0:43 [Bug fortran/65841] New: Seg fault on intrinsic assignment to allocatable derived type with allocatable component damian at sourceryinstitute dot org
                   ` (2 preceding siblings ...)
  2015-04-23  7:39 ` dominiq at lps dot ens.fr
@ 2015-04-27 17:34 ` vehre at gcc dot gnu.org
  2015-05-05  9:10 ` vehre at gcc dot gnu.org
  2015-10-18 15:01 ` mikael at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-04-27 17:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from vehre at gcc dot gnu.org ---
Author: vehre
Date: Mon Apr 27 17:34:11 2015
New Revision: 222477

URL: https://gcc.gnu.org/viewcvs?rev=222477&root=gcc&view=rev
Log:
gcc/fortran
2015-04-27  Andre Vehreschild  <vehre@gmx.de>

        PR fortran/59678
        PR fortran/65841
        * trans-array.c (duplicate_allocatable): Fixed deep copy of
        allocatable components, which are liable for copy only, when
        they are allocated.
        (gfc_duplicate_allocatable): Add deep-copy code into if
        component allocated block. Needed interface change for that.
        (gfc_copy_allocatable_data): Supplying NULL_TREE for code to
        add into if-block for checking whether a component was
        allocated.
        (gfc_duplicate_allocatable_nocopy): Likewise.
        (structure_alloc_comps): Likewise.
        * trans-array.h: Likewise.
        * trans-expr.c (gfc_trans_alloc_subarray_assign): Likewise.
        * trans-openmp.c (gfc_walk_alloc_comps): Likewise.

gcc/testsuite
2015-04-27  Andre Vehreschild  <vehre@gmx.de>

        PR fortran/59678
        PR fortran/65841
        * gfortran.dg/alloc_comp_deep_copy_1.f03: New test.
        * gfortran.dg/alloc_comp_deep_copy_2.f03: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/alloc_comp_deep_copy_1.f03
    trunk/gcc/testsuite/gfortran.dg/alloc_comp_deep_copy_2.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/fortran/trans-array.h
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans-openmp.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/65841] Seg fault on intrinsic assignment to allocatable derived type with allocatable component
  2015-04-22  0:43 [Bug fortran/65841] New: Seg fault on intrinsic assignment to allocatable derived type with allocatable component damian at sourceryinstitute dot org
                   ` (3 preceding siblings ...)
  2015-04-27 17:34 ` vehre at gcc dot gnu.org
@ 2015-05-05  9:10 ` vehre at gcc dot gnu.org
  2015-10-18 15:01 ` mikael at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-05-05  9:10 UTC (permalink / raw)
  To: gcc-bugs

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

vehre at gcc dot gnu.org changed:

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

--- Comment #6 from vehre at gcc dot gnu.org ---
Fixed with r222477. No complaints so far, closing.


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

* [Bug fortran/65841] Seg fault on intrinsic assignment to allocatable derived type with allocatable component
  2015-04-22  0:43 [Bug fortran/65841] New: Seg fault on intrinsic assignment to allocatable derived type with allocatable component damian at sourceryinstitute dot org
                   ` (4 preceding siblings ...)
  2015-05-05  9:10 ` vehre at gcc dot gnu.org
@ 2015-10-18 15:01 ` mikael at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-10-18 15:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Mikael Morin <mikael at gcc dot gnu.org> ---
Author: mikael
Date: Sun Oct 18 15:01:03 2015
New Revision: 228945

URL: https://gcc.gnu.org/viewcvs?rev=228945&root=gcc&view=rev
Log:
        PR fortran/67721
        PR fortran/67818
        Backport from mainline r222477:

        2015-04-27  Andre Vehreschild  <vehre@gmx.de>

        PR fortran/59678
        PR fortran/65841
gcc/fortran/
        * trans-array.c (duplicate_allocatable): Fixed deep copy of
        allocatable components, which are liable for copy only, when
        they are allocated.
        (gfc_duplicate_allocatable): Add deep-copy code into if
        component allocated block. Needed interface change for that.
        (gfc_copy_allocatable_data): Supplying NULL_TREE for code to
        add into if-block for checking whether a component was
        allocated.
        (gfc_duplicate_allocatable_nocopy): Likewise.
        (structure_alloc_comps): Likewise.
        * trans-array.h: Likewise.
        * trans-expr.c (gfc_trans_alloc_subarray_assign): Likewise.
        * trans-openmp.c (gfc_walk_alloc_comps): Likewise.
gcc/testsuite/
        * gfortran.dg/alloc_comp_deep_copy_1.f03: New test.
        * gfortran.dg/alloc_comp_deep_copy_2.f03: New test.


Added:
    branches/gcc-5-branch/gcc/testsuite/gfortran.dg/alloc_comp_deep_copy_1.f03
    branches/gcc-5-branch/gcc/testsuite/gfortran.dg/alloc_comp_deep_copy_2.f03
Modified:
    branches/gcc-5-branch/gcc/fortran/ChangeLog
    branches/gcc-5-branch/gcc/fortran/trans-array.c
    branches/gcc-5-branch/gcc/fortran/trans-array.h
    branches/gcc-5-branch/gcc/fortran/trans-expr.c
    branches/gcc-5-branch/gcc/fortran/trans-openmp.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog


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

end of thread, other threads:[~2015-10-18 15:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-22  0:43 [Bug fortran/65841] New: Seg fault on intrinsic assignment to allocatable derived type with allocatable component damian at sourceryinstitute dot org
2015-04-22 13:03 ` [Bug fortran/65841] " pault at gcc dot gnu.org
2015-04-22 14:24 ` dominiq at lps dot ens.fr
2015-04-23  7:39 ` dominiq at lps dot ens.fr
2015-04-27 17:34 ` vehre at gcc dot gnu.org
2015-05-05  9:10 ` vehre at gcc dot gnu.org
2015-10-18 15:01 ` 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).