public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/43931] New: coarrays: Wrong code (segfault) with allocatable coarrays
@ 2010-04-29 9:15 burnus at gcc dot gnu dot org
2010-04-29 13:49 ` [Bug fortran/43931] " burnus at gcc dot gnu dot org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-04-29 9:15 UTC (permalink / raw)
To: gcc-bugs
The following program segfaults at run time. gdb does not show a backtrace and
valgrind just has:
==27936== Jump to the invalid address stated on the next line
==27936== at 0x8: ???
==27936== Address 0x8 is not stack'd, malloc'd or (recently) free'd
The program is minimal. Removing either the "CALL" or the "ALLOCATE" or "four"
causes non-segfaulting code.
program test
implicit none
call one()
contains
subroutine one()
integer, allocatable :: a(:)[:,:,:]
allocate(a(1)[-4:9,8,4:*])
end subroutine one
subroutine four(C)
integer, allocatable :: C(:)[:]
end subroutine four
end program test
--
Summary: coarrays: Wrong code (segfault) with allocatable
coarrays
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: burnus at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43931
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/43931] coarrays: Wrong code (segfault) with allocatable coarrays
2010-04-29 9:15 [Bug fortran/43931] New: coarrays: Wrong code (segfault) with allocatable coarrays burnus at gcc dot gnu dot org
@ 2010-04-29 13:49 ` burnus at gcc dot gnu dot org
2010-04-29 13:50 ` burnus at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-04-29 13:49 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2010-04-29 13:49 -------
Created an attachment (id=20515)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20515&action=view)
142t.optimized dump
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43931
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/43931] coarrays: Wrong code (segfault) with allocatable coarrays
2010-04-29 9:15 [Bug fortran/43931] New: coarrays: Wrong code (segfault) with allocatable coarrays burnus at gcc dot gnu dot org
2010-04-29 13:49 ` [Bug fortran/43931] " burnus at gcc dot gnu dot org
@ 2010-04-29 13:50 ` burnus at gcc dot gnu dot org
2010-04-29 14:34 ` burnus at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-04-29 13:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from burnus at gcc dot gnu dot org 2010-04-29 13:49 -------
Created an attachment (id=20516)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20516&action=view)
Assembler (x86-64-linux)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43931
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/43931] coarrays: Wrong code (segfault) with allocatable coarrays
2010-04-29 9:15 [Bug fortran/43931] New: coarrays: Wrong code (segfault) with allocatable coarrays burnus at gcc dot gnu dot org
2010-04-29 13:49 ` [Bug fortran/43931] " burnus at gcc dot gnu dot org
2010-04-29 13:50 ` burnus at gcc dot gnu dot org
@ 2010-04-29 14:34 ` burnus at gcc dot gnu dot org
2010-04-30 18:31 ` burnus at gcc dot gnu dot org
2010-04-30 18:36 ` burnus at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-04-29 14:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from burnus at gcc dot gnu dot org 2010-04-29 14:34 -------
The issue is that
a.dim[]
is too small, which was traced by Alexander Monakov (thanks!).
This is in turn due to:
gfc_get_array_descriptor_base (int dimen, int codimen, bool restricted)
{
int idx = 2 * (dimen - 1) + restricted;
[...]
gfc_array_descriptor_base[idx] = fat_type;
Possible patch (untested) below.
However, as coarrays do not need to agree on the coranks (except for
allocatable ones), coarrays with different corank are compatible. Ditto for
passing a coarray to a non-coarray. Thus, the patch below will cause problems
for
integer :: coarray(1)[2,*]
call foo(coarray)
to
subroutine foo(coarray)
integer :: coarray(1)[*]
or to
subroutine foo(array)
integer :: array(1)
as the coranks don't agree and thus not the type. I have to think about how to
solve this best. For allocatable coarrays there is no problem, as there the
coranks have to agree.
Index: trans-types.c
===================================================================
--- trans-types.c (revision 158895)
+++ trans-types.c (working copy)
@@ -1542,7 +1542,7 @@
{
tree fat_type, fieldlist, decl, arraytype;
char name[16 + 2*GFC_RANK_DIGITS + 1 + 1];
- int idx = 2 * (dimen - 1) + restricted;
+ int idx = 2 * (codimen + dimen - 1) + restricted;
gcc_assert (dimen >= 1 && codimen + dimen <= GFC_MAX_DIMENSIONS);
if (gfc_array_descriptor_base[idx])
@@ -1551,8 +1551,7 @@
/* Build the type node. */
fat_type = make_node (RECORD_TYPE);
- sprintf (name, "array_descriptor" GFC_RANK_PRINTF_FORMAT "_"
- GFC_RANK_PRINTF_FORMAT, dimen, codimen);
+ sprintf (name, "array_descriptor" GFC_RANK_PRINTF_FORMAT, dimen + codimen);
TYPE_NAME (fat_type) = get_identifier (name);
/* Add the data member as the first element of the descriptor. */
@@ -1629,8 +1628,7 @@
type_name = IDENTIFIER_POINTER (tmp);
else
type_name = "unknown";
- sprintf (name, "array" GFC_RANK_PRINTF_FORMAT "_"
- GFC_RANK_PRINTF_FORMAT "_%.*s", dimen, codimen,
+ sprintf (name, "array" GFC_RANK_PRINTF_FORMAT "_%.*s", dimen + codimen,
GFC_MAX_SYMBOL_LEN, type_name);
TYPE_NAME (fat_type) = get_identifier (name);
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43931
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/43931] coarrays: Wrong code (segfault) with allocatable coarrays
2010-04-29 9:15 [Bug fortran/43931] New: coarrays: Wrong code (segfault) with allocatable coarrays burnus at gcc dot gnu dot org
` (2 preceding siblings ...)
2010-04-29 14:34 ` burnus at gcc dot gnu dot org
@ 2010-04-30 18:31 ` burnus at gcc dot gnu dot org
2010-04-30 18:36 ` burnus at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-04-30 18:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from burnus at gcc dot gnu dot org 2010-04-30 18:31 -------
Subject: Bug 43931
Author: burnus
Date: Fri Apr 30 18:30:53 2010
New Revision: 158941
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158941
Log:
2010-04-30 Tobias Burnus Mburnus@net-b.de>
PR fortran/18918
PR fortran/43931
* trans-types.c (gfc_get_array_descriptor_base): Fix index
calculation for array descriptor types.
2010-04-30 Tobias Burnus Mburnus@net-b.de>
PR fortran/18918
PR fortran/43931
* gfortran.dg/coarray_13.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/coarray_13.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-types.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43931
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/43931] coarrays: Wrong code (segfault) with allocatable coarrays
2010-04-29 9:15 [Bug fortran/43931] New: coarrays: Wrong code (segfault) with allocatable coarrays burnus at gcc dot gnu dot org
` (3 preceding siblings ...)
2010-04-30 18:31 ` burnus at gcc dot gnu dot org
@ 2010-04-30 18:36 ` burnus at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-04-30 18:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from burnus at gcc dot gnu dot org 2010-04-30 18:36 -------
Close as FIXED.
With the other issues (passing as actual arguments) I will deal - but not as
part of this PR. See PR 18918 for the general coarray tracking.
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43931
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-04-30 18:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-29 9:15 [Bug fortran/43931] New: coarrays: Wrong code (segfault) with allocatable coarrays burnus at gcc dot gnu dot org
2010-04-29 13:49 ` [Bug fortran/43931] " burnus at gcc dot gnu dot org
2010-04-29 13:50 ` burnus at gcc dot gnu dot org
2010-04-29 14:34 ` burnus at gcc dot gnu dot org
2010-04-30 18:31 ` burnus at gcc dot gnu dot org
2010-04-30 18:36 ` burnus 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).