From: Andre Vehreschild <vehre@gmx.de>
To: GCC-Patches-ML <gcc-patches@gcc.gnu.org>,
GCC-Fortran-ML <fortran@gcc.gnu.org>
Subject: [PATCH, Fortran, pr70696, v1] [Coarray] ICE on EVENT POST of host-associated EVENT_TYPE coarray
Date: Thu, 12 Jan 2017 11:46:00 -0000 [thread overview]
Message-ID: <20170112124558.6f8de516@vepi2> (raw)
[-- Attachment #1: Type: text/plain, Size: 471 bytes --]
Hi all,
attached patch fixes the ICE when using an event in a subroutine. The reason
for the ICE was that the backend_decl of the symbol to event on was not set
when accessed. The patch ensures this. Furthermore did I fix a invalid memory
access in the caf_single lib, where to less memory was allocated in the
registration of the event.
Bootstraps and regtests ok on x86_64-linux/F25. Ok for trunk?
Regards,
Andre
--
Andre Vehreschild * Email: vehre ad gmx dot de
[-- Attachment #2: pr70696_v1.clog --]
[-- Type: text/plain, Size: 523 bytes --]
gcc/testsuite/ChangeLog:
2017-01-12 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/70696
* gfortran.dg/coarray/event_3.f08: New test.
gcc/fortran/ChangeLog:
2017-01-12 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/70696
* trans-expr.c (gfc_get_tree_for_caf_expr): Ensure the backend_decl
is valid before accessing it.
libgfortran/ChangeLog:
2017-01-12 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/70696
* caf/single.c (_gfortran_caf_register): Allocate enough memory for
the event counter.
[-- Attachment #3: pr70696_v1.patch --]
[-- Type: text/x-patch, Size: 2203 bytes --]
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index caaee6b..01b7dd2 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -1838,6 +1838,10 @@ gfc_get_tree_for_caf_expr (gfc_expr *expr)
"component at %L is not supported", &expr->where);
}
+ /* Make sure the backend_decl is present before accessing it. */
+ if (expr->symtree->n.sym->backend_decl == NULL_TREE)
+ expr->symtree->n.sym->backend_decl
+ = gfc_get_symbol_decl (expr->symtree->n.sym);
caf_decl = expr->symtree->n.sym->backend_decl;
gcc_assert (caf_decl);
if (expr->symtree->n.sym->ts.type == BT_CLASS)
diff --git a/gcc/testsuite/gfortran.dg/coarray/event_3.f08 b/gcc/testsuite/gfortran.dg/coarray/event_3.f08
new file mode 100644
index 0000000..f6e28b7
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray/event_3.f08
@@ -0,0 +1,20 @@
+! { dg-do run }
+!
+! Check PR fortran/70696 is fixed.
+
+program global_event
+ use iso_fortran_env , only : event_type
+ implicit none
+ type(event_type) :: x[*]
+
+ call exchange
+ contains
+ subroutine exchange
+ integer :: cnt
+ event post(x[1])
+ event post(x[1])
+ call event_query(x, cnt)
+ if (cnt /= 2) error stop 1
+ event wait(x, until_count=2)
+ end subroutine
+end
diff --git a/libgfortran/caf/single.c b/libgfortran/caf/single.c
index cf78a1a..8d3bcbf 100644
--- a/libgfortran/caf/single.c
+++ b/libgfortran/caf/single.c
@@ -141,9 +141,12 @@ _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
caf_single_token_t single_token;
if (type == CAF_REGTYPE_LOCK_STATIC || type == CAF_REGTYPE_LOCK_ALLOC
- || type == CAF_REGTYPE_CRITICAL || type == CAF_REGTYPE_EVENT_STATIC
- || type == CAF_REGTYPE_EVENT_ALLOC)
+ || type == CAF_REGTYPE_CRITICAL)
local = calloc (size, sizeof (bool));
+ else if (type == CAF_REGTYPE_EVENT_STATIC || type == CAF_REGTYPE_EVENT_ALLOC)
+ /* In the event_(wait|post) function the counter for events is a uint32,
+ so better allocate enough memory here. */
+ local = calloc (size, sizeof (uint32_t));
else if (type == CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY)
local = NULL;
else
next reply other threads:[~2017-01-12 11:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-12 11:46 Andre Vehreschild [this message]
2017-01-12 18:11 ` Jerry DeLisle
2017-01-13 10:23 ` Andre Vehreschild
2017-01-18 12:32 ` [PATCH, Fortran, pr70696, v2] " Andre Vehreschild
2017-01-18 17:41 ` Jerry DeLisle
2017-01-18 18:37 ` Andre Vehreschild
2017-01-19 12:13 ` Andre Vehreschild
2017-01-19 15:02 ` Steve Kargl
2017-01-19 15:54 ` Andre Vehreschild
2017-01-29 14:48 ` [PATCH, Fortran, pr70696, gcc-6, v1-3] " Andre Vehreschild
2017-01-29 15:57 ` [PATCH, Fortran, pr70696/68887, gcc-6, v1] Forgot to commit runtime part Andre Vehreschild
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170112124558.6f8de516@vepi2 \
--to=vehre@gmx.de \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).