gnu/gcc/4eda76ca63df945f4c22d76aeca263bd9457887d libgfortran: [PR127684] caf_shmem: SYNC IMAGES hang on terminated image
SYNC IMAGES hung when an image of the image set stopped or failed while
another image of the set was waiting in the statement.
An image that found a stopped or failed image in its set returned at once
with STAT=, without counting the statement for the other images of the
set, so an image already waiting for it was never released. The
supervisor, the parent process that starts the images and waits for them
to exit, also woke the waiting images without holding the table lock, so
a wakeup could be lost.
Each image now counts the statement for every active image of its set,
also when one of them has stopped, so that corresponding statements keep
pairing (F2023 11.7.4). With a stopped image the statement then only has
the effect of SYNC MEMORY, and failed images are skipped (F2023 11.7.11).
Every change of an image's status to stopped or failed now goes through
the new notify_image_terminated, which holds the table lock and wakes
every image waiting in SYNC IMAGES. The image sets its own status in
STOP or FAIL IMAGE; the supervisor sets it when an image exited or was
killed by a signal without doing so. The Windows version of the
supervisor is not changed.
Assisted-by: Claude Opus 5.5
PR libfortran/127684
libgfortran/ChangeLog:
* caf/shmem.c (_gfortran_caf_sync_images): Do not return early for
a stopped or failed image. Check the images only when one of them
terminated.
(mark_stopped): Use notify_image_terminated.
(_gfortran_caf_fail_image): Likewise.
* caf/shmem/supervisor.c (supervisor_main_loop): Likewise. Do not
signal the images waiting in sync_table.
* caf/shmem/sync.c (stopped_image_in): New function.
(sync_table): Return whether an image of the set terminated. Stop
waiting when an image of the set stopped.
(notify_image_terminated): New function.
* caf/shmem/sync.h (sync_table): Return bool.
(notify_image_terminated): Declare.
gcc/testsuite/ChangeLog:
* gfortran.dg/coarray/sync_images_failed_1.f90: New test.
* gfortran.dg/coarray/sync_images_stopped_2.f90: New test.
* gfortran.dg/coarray/sync_images_stopped_3.f90: New test.
7 files changed