https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127347

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <[email protected]>:

https://gcc.gnu.org/g:73309e444dea1ee71346a58b7e4bbaa792de5d19

commit r17-4842-g73309e444dea1ee71346a58b7e4bbaa792de5d19
Author: Jerry DeLisle <[email protected]>
Date:   Thu Sep 24 12:57:23 2026 -0700

    libgfortran: [PR127347] caf_shmem: drop images killed by a signal from
teams

    An image that terminates without STOP or FAIL IMAGE, e.g. when it is
    killed by a signal, cannot drop itself from the barriers of its teams,
    so the other images blocked forever in their next image control
    statement.  Only the supervisor notices such an image, and it has no
    access to the teams the image was a member of.

    Every team now registers itself with the supervisor when it is formed,
    which happens once per team, so that the supervisor can walk the teams
    and do for a killed image what the image itself does for a STOP.
    Entries are pushed onto the list without a lock, so that an image
    killed while registering a team cannot block the supervisor.

    An image killed this way stays a failed image (F2023 5.3.6): the other
    images of its teams carry on and report it through STAT=.

    Reporting it needs SYNC ALL and SYNC TEAM to check the images of the
    team after synchronizing.  They only did so when they had not
    synchronized, which is the case for a stopped image; with a failed
    image the active images are synchronized (F2023 11.7.11) and the only
    other check ran before the barrier, so an image failing while the
    others already waited in the statement left STAT= zero.

    Assisted-by: Claude Opus 5.5

            PR libfortran/127347

    libgfortran/ChangeLog:

            * caf/shmem.c (_gfortran_caf_init): Synchronize without the checks
            of the SYNC ALL statement.
            (_gfortran_caf_sync_all, _gfortran_caf_sync_team): Report the
images
            of the team that terminated before the images synchronized.
            (_gfortran_caf_form_team): Register the team.
            * caf/shmem/collective_subroutine.c (collsub_sync): Adjust.
            * caf/shmem/counter_barrier.c (counter_barrier_init): Initialize
the
            new fields.
            (counter_barrier_add_locked): Count the images removed from the
            barrier.
            (next_round): Take that count as a completed round ends.
            (wait_round, counter_barrier_wait_abortable): Report it for the
round
            the image took part in.
            * caf/shmem/counter_barrier.h (counter_barrier): Add terminated and
            round_terminated.
            (counter_barrier_wait_abortable): Adjust.
            * caf/shmem/supervisor.c (ensure_shmem_initialization): Initialize
            the list of teams.  Register the initial team.
            (supervisor_main_loop): Drop an image that terminated without
            leaving its teams from them.
            * caf/shmem/supervisor.h (supervisor): Add teams.
            * caf/shmem/sync.c (sync_all, sync_team_unless_stopped): Report the
            images that terminated.
            * caf/shmem/sync.h (sync_all, sync_team_unless_stopped): Adjust.
            * caf/shmem/teams_mgmt.c (team_terminated_images)
            (update_teams_images_locked, leave_team): Take the team's image
            info.
            (register_team, update_registered_teams): New functions.
            * caf/shmem/teams_mgmt.h (shmem_image_info): Add next_team.
            (register_team, update_registered_teams): Declare.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/coarray/signal_sync_1.f90: New test.
            * gfortran.dg/coarray/signal_team_1.f90: New test.
            * gfortran.dg/coarray/sync_failed_stat_1.f90: New test.

Reply via email to