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

--- Comment #1 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:b922224de8e06650f86df59143b17c4df0c08381

commit r17-5493-gb922224de8e06650f86df59143b17c4df0c08381
Author: Jerry DeLisle <[email protected]>
Date:   Sat Oct 17 09:59:16 2026 -0700

    libgfortran: [PR127973] caf_shmem: collectives report an exhausted pool

    When a collective subroutine could not grow the team's buffer in the
    shared memory pool, the image growing it error terminated while holding
    the buffer's mutex, so the other images hung instead of getting STAT=
    and ERRMSG=.  The buffer was also allocated without the allocator lock.

    get_collsub_buf now allocates under the allocator lock and, on failure,
    sets a flag in the team's collective state, so that every image of the
    collective fails; the images clear the flag between two barrier rounds.
    collsub_reduce_array and collsub_broadcast_array return a collsub_result,
    and the _gfortran_caf_co_* entry points report an exhausted pool through
    STAT= and ERRMSG=.

    Assisted-by: Claude Opus 5.5

            PR libfortran/127973

    libgfortran/ChangeLog:

            * caf/shmem.c (report_collective): New function.
            (_gfortran_caf_co_broadcast, _gfortran_caf_co_sum)
            (_gfortran_caf_co_min, _gfortran_caf_co_max)
            (_gfortran_caf_co_reduce): Use it.
            * caf/shmem/collective_subroutine.c (collsub_init_supervisor):
            Initialize alloc_failed.
            (get_collsub_buf): Return false instead of terminating when the
            buffer cannot be grown.  Take the allocator lock.
            (collsub_no_memory): New function.
            (collsub_reduce_array, collsub_broadcast_array): Return a
            collsub_result.  Use collsub_no_memory.
            * caf/shmem/collective_subroutine.h (struct collsub_shared): Add
            alloc_failed.
            (collsub_result): New enum.
            (collsub_broadcast_array, collsub_reduce_array): Return it.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/coarray/collective_pool_exhausted_1.f90: New test.

Reply via email to