This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Fortran, Patch, pr65795, v1] Segfault (invalid write) for ALLOCATE statement involving COARRAYS
- From: Andre Vehreschild <vehre at gmx dot de>
- To: Dominique d'HumiÃres <dominiq at lps dot ens dot fr>
- Cc: "jvdelisle at charter dot net" <jvdelisle at charter dot net>, fortran at gcc dot gnu dot org, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 4 Apr 2016 11:36:02 +0200
- Subject: Re: [Fortran, Patch, pr65795, v1] Segfault (invalid write) for ALLOCATE statement involving COARRAYS
- Authentication-results: sourceware.org; auth=none
- References: <7DD7789A-5E9B-4CFF-B40B-D92665A5AB27 at lps dot ens dot fr> <F5DC95B1-A4F9-4A23-8C26-063E48814D28 at gmx dot de> <5C92C102-BD0C-4FC9-ADDE-0E2CBB000E2C at lps dot ens dot fr>
Hi Jerry, hi Dominique,
Jerry, thank you for the review. Committed to
trunk as r234710 and to
gcc-5-branch as r234711
including the additional option Dominique noted I had missed. Thank for
pointing that out, Dominique.
Regards,
Andre
On Sun, 3 Apr 2016 23:46:34 +0200
Dominique d'HumiÃres <dominiq@lps.ens.fr> wrote:
> > Le 3 avr. 2016 Ã 23:38, Andre Vehreschild <vehre@gmx.de> a Ãcrit :
> >
> > Hi Dominique,
> >
> > I thought that was implicit, isn't it?
>
> I donât think so and I see in the log files
>
> gcc/testsuite/gfortran4/gfortran.sum:UNRESOLVED: gfortran.dg/coarray_allocate_6.f08 -O0 scan-tree-dump-not original "c.caf.x = 0B"
>
> > Is only the removal of the file implicit?
>
> Yes,
>
> > I will add the option to be on the safe side.
>
> Thanks,
>
> Dominique
>
> >
> > - Andre
> >
> > Am 3. April 2016 22:57:48 MESZ, schrieb "Dominique d'HumiÃres" <dominiq@lps.ens.fr>:
> > Andre,
> >
> > Does not the test gfortran.dg/coarray_allocate_6.f08 require a -fdump-tree-original in the dg-options list?
> >
> > Thanks for the patch,
> >
> > Dominique
> >
> >
> > --
> > Andre Vehreschild * Kreuzherrenstr. 8 * 52062 Aachen
> > Tel.: +49 241 929 10 18 * vehre@gmx.de
>
--
Andre Vehreschild * Email: vehre ad gmx dot de
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (Revision 234709)
+++ gcc/fortran/ChangeLog (Arbeitskopie)
@@ -1,3 +1,11 @@
+2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ PR fortran/65795
+ * trans-array.c (gfc_array_allocate): When the array is a coarray,
+ do not nullyfing its allocatable components in array_allocate, because
+ the nullify missed the array ref and nullifies the wrong component.
+ Cosmetics.
+
2016-03-29 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/70397
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c (Revision 234709)
+++ gcc/fortran/trans-array.c (Arbeitskopie)
@@ -5550,8 +5550,8 @@
else
gfc_add_expr_to_block (&se->pre, set_descriptor);
- if ((expr->ts.type == BT_DERIVED)
- && expr->ts.u.derived->attr.alloc_comp)
+ if (expr->ts.type == BT_DERIVED && expr->ts.u.derived->attr.alloc_comp
+ && !coarray)
{
tmp = gfc_nullify_alloc_comp (expr->ts.u.derived, se->expr,
ref->u.ar.as->rank);
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 234709)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -1,3 +1,8 @@
+2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ PR fortran/65795
+ * gfortran.dg/coarray_allocate_6.f08: New test.
+
2016-04-04 Richard Biener <rguenther@suse.de>
PR rtl-optimization/70484
Index: gcc/testsuite/gfortran.dg/coarray_allocate_6.f08
===================================================================
--- gcc/testsuite/gfortran.dg/coarray_allocate_6.f08 (nicht existent)
+++ gcc/testsuite/gfortran.dg/coarray_allocate_6.f08 (Arbeitskopie)
@@ -0,0 +1,27 @@
+! { dg-do run }
+! { dg-options "-fcoarray=single -fdump-tree-original" }
+
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+! Test fix for pr65795.
+
+implicit none
+
+type t2
+ integer, allocatable :: x
+end type t2
+
+type t3
+ type(t2), allocatable :: caf[:]
+end type t3
+
+!type(t3), save, target :: c, d
+type(t3), target :: c, d
+integer :: stat
+
+allocate(c%caf[*], stat=stat)
+end
+
+! Besides checking that the executable does not crash anymore, check
+! that the cause has been remove.
+! { dg-final { scan-tree-dump-not "c.caf.x = 0B" "original" } }
+
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (Revision 234706)
+++ gcc/fortran/ChangeLog (Arbeitskopie)
@@ -1,3 +1,11 @@
+2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ PR fortran/65795
+ * trans-array.c (gfc_array_allocate): When the array is a coarray,
+ do not nullyfing its allocatable components in array_allocate, because
+ the nullify missed the array ref and nullifies the wrong component.
+ Cosmetics.
+
2016-03-28 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/70397
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c (Revision 234706)
+++ gcc/fortran/trans-array.c (Arbeitskopie)
@@ -5390,8 +5390,8 @@
else
gfc_add_expr_to_block (&se->pre, set_descriptor);
- if ((expr->ts.type == BT_DERIVED)
- && expr->ts.u.derived->attr.alloc_comp)
+ if (expr->ts.type == BT_DERIVED && expr->ts.u.derived->attr.alloc_comp
+ && !coarray)
{
tmp = gfc_nullify_alloc_comp (expr->ts.u.derived, se->expr,
ref->u.ar.as->rank);
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 234706)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -1,3 +1,8 @@
+2016-04-04 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ PR fortran/65795
+ * gfortran.dg/coarray_allocate_6.f08: New test.
+
2016-04-01 Ilya Enkovich <enkovich.gnu@gmail.com>
Backport from mainline r234666.
Index: gcc/testsuite/gfortran.dg/coarray_allocate_6.f08
===================================================================
--- gcc/testsuite/gfortran.dg/coarray_allocate_6.f08 (nicht existent)
+++ gcc/testsuite/gfortran.dg/coarray_allocate_6.f08 (Arbeitskopie)
@@ -0,0 +1,27 @@
+! { dg-do run }
+! { dg-options "-fcoarray=single -fdump-tree-original" }
+
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+! Test fix for pr65795.
+
+implicit none
+
+type t2
+ integer, allocatable :: x
+end type t2
+
+type t3
+ type(t2), allocatable :: caf[:]
+end type t3
+
+!type(t3), save, target :: c, d
+type(t3), target :: c, d
+integer :: stat
+
+allocate(c%caf[*], stat=stat)
+end
+
+! Besides checking that the executable does not crash anymore, check
+! that the cause has been remove.
+! { dg-final { scan-tree-dump-not "c.caf.x = 0B" "original" } }
+