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

--- 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:383e60c260ce5cf951123ef120491732d23ffcee

commit r17-5279-g383e60c260ce5cf951123ef120491732d23ffcee
Author: Jerry DeLisle <[email protected]>
Date:   Mon Oct 5 11:04:55 2026 -0700

    libgfortran: [PR127751] caf_shmem: report exhausted shared memory pool

    ALLOCATE of a coarray that did not fit into the shared memory pool
    returned STAT=0, and the first access to the coarray segfaulted, because
    the allocator handed out memory past the end of the pool.

    The allocator now returns a null pointer when the pool is exhausted.
    ALLOCATE of a coarray and FORM TEAM report it through STAT=, or error
    terminate; the other allocations of the library terminate the image with
    a message.

    Assisted-by: Claude Opus 5.5

            PR libfortran/127751

    libgfortran/ChangeLog:

            * caf/shmem.c (_gfortran_caf_register): Handle a failed allocation
            of a component.
            (_gfortran_caf_form_team): Report a failed allocation.
            * caf/shmem/alloc.c (get_memory_by_id_internal): Return NULL when
            the shared memory is exhausted.
            * caf/shmem/alloc.h (alloc_get_memory_by_id): Document it.
            * caf/shmem/allocator.c (allocator_shared_malloc_or_die): New
            function.
            * caf/shmem/allocator.h (allocator_shared_malloc): Document the
null
            result.
            (allocator_shared_malloc_or_die): Declare.
            * caf/shmem/collective_subroutine.c (collsub_init_supervisor)
            (get_collsub_buf): Use allocator_shared_malloc_or_die.
            * caf/shmem/hashmap.c (hashmap_init_supervisor)
            (enlarge_hashmap_mem): Likewise.
            * caf/shmem/sync.c (sync_init_supervisor): Likewise.
            * caf/shmem/shared_memory.c (shared_memory_get_mem_with_alignment):
            Return a null pointer when the shared memory is exhausted.
            * caf/shmem/supervisor.c (ensure_shmem_initialization): Terminate
            when the initial team cannot be allocated.

    gcc/testsuite/ChangeLog:

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

Reply via email to