Skip to content

Commit 0696306

Browse files
committed
Null array-descriptor in mpi-token causing segfault on finalize.
This patch ensures that the array descriptor stored in the mpi-caf-token is set to NULL consistently, when no real descriptor is stored in it. Further does the patch ensure freeing memory with gcc-7. The testcases have been actived again for annoucing their passing.
1 parent 3ccb984 commit 0696306

File tree

3 files changed

+16
-26
lines changed

3 files changed

+16
-26
lines changed

src/mpi/mpi_caf.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,12 @@ PREFIX (finalize) (void)
464464
MPI_Win_free (mpi_token->desc);
465465
free (mpi_token->desc);
466466
}
467-
#else
467+
#else // GCC_GE_7
468468
# ifndef CAF_MPI_LOCK_UNLOCK
469469
MPI_Win_unlock_all(*p);
470470
# endif // CAF_MPI_LOCK_UNLOCK
471+
#endif // GCC_GE_7
471472
MPI_Win_free(p);
472-
#endif
473473
free(tmp_tot);
474474
tmp_tot = prev;
475475
}
@@ -541,23 +541,21 @@ PREFIX (register) (size_t size, caf_register_t type, caf_token_t *token,
541541
mpi_token = (mpi_caf_token_t *) *token;
542542
p = TOKEN(mpi_token);
543543

544-
if (type == CAF_REGTYPE_COARRAY_ALLOC_ALLOCATE_ONLY
545-
|| type == CAF_REGTYPE_COARRAY_ALLOC
546-
|| type == CAF_REGTYPE_COARRAY_STATIC)
544+
if ((type == CAF_REGTYPE_COARRAY_ALLOC_ALLOCATE_ONLY
545+
|| type == CAF_REGTYPE_COARRAY_ALLOC
546+
|| type == CAF_REGTYPE_COARRAY_STATIC)
547+
&& GFC_DESCRIPTOR_RANK (desc) != 0)
547548
{
548-
if (GFC_DESCRIPTOR_RANK (desc) == 0)
549-
mpi_token->desc = NULL;
550-
else
551-
{
552-
int ierr;
553-
size_t desc_size = sizeof (gfc_descriptor_t) + /*GFC_DESCRIPTOR_RANK (desc)*/
554-
GFC_MAX_DIMENSIONS * sizeof (descriptor_dimension);
555-
mpi_token->desc = (MPI_Win *)malloc (sizeof (MPI_Win));
556-
ierr = MPI_Win_create (desc, desc_size, 1, mpi_info_same_size,
557-
CAF_COMM_WORLD, mpi_token->desc);
558-
CAF_Win_lock_all (*(mpi_token->desc));
559-
}
549+
int ierr;
550+
size_t desc_size = sizeof (gfc_descriptor_t) + /*GFC_DESCRIPTOR_RANK (desc)*/
551+
GFC_MAX_DIMENSIONS * sizeof (descriptor_dimension);
552+
mpi_token->desc = (MPI_Win *)malloc (sizeof (MPI_Win));
553+
ierr = MPI_Win_create (desc, desc_size, 1, mpi_info_same_size,
554+
CAF_COMM_WORLD, mpi_token->desc);
555+
CAF_Win_lock_all (*(mpi_token->desc));
560556
}
557+
else
558+
mpi_token->desc = NULL;
561559

562560
#if MPI_VERSION >= 3
563561
if (type != CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY)

src/tests/integration/events/async-hello.F90

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ program main
6969
end do
7070

7171
sync all
72-
! Hardwire failure with GCC 7 (remove this preprocessor conditional after the silent failure with GCC 7 has been eliminated)
73-
#if __GNUC__ >= 7
74-
#else
7572
if (me==1) print *,"Test passed."
76-
#endif
7773

7874
end associate
7975

src/tests/regression/reported/issue-293-silent-event-failure.F90

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ program main
4141

4242
if (num_images()<3) error stop "exposing issue 293 requires num_images()>=3"
4343
event post(test_post)
44-
! Hardwire failure with GCC 7 (remove this preprocessor conditional after the silent failure with GCC 7 has been eliminated)
45-
#if __GNUC__ >= 7
46-
#else
47-
if (this_image()==1) print *,"Test passed."
48-
#endif
44+
if (this_image()==1) print *,"Test passed."
4945

5046
end program

0 commit comments

Comments
 (0)