Le 30/10/2026 à 14:00, Jerry DeLisle a écrit :
See the attached patch. This is the second of the two patches making things a bit mor reliable.

Regression tested on x86_64.

OK for mainline?
OK.


Regards,

Jerry

---

libgfortran: [PR127751] caf_shmem: report a full table of coarray ids

When ALLOCATE of a coarray needed a larger table of coarray ids and the
shared memory pool could not hold it, the image error terminated while
holding the allocator lock, so the other images hung.  The table is now
left unchanged and the failure is reported through STAT= and ERRMSG=.
Old tables were also freed with their number of entries instead of their
size in bytes.

A failed ALLOCATE of a component of a coarray freed the token of the
component, so retrying the ALLOCATE freed it twice.  The token is now kept.

Assisted-by: Claude Opus 5.5

     PR libfortran/127751

libgfortran/ChangeLog:

     * caf/shmem.c (_gfortran_caf_register): Keep the token of a
     component when its allocation fails.
     * caf/shmem/alloc.c (get_memory_by_id_internal): Free the memory and
     return NULL when the id cannot be entered into the hashmap.
     * caf/shmem/hashmap.c (enlarge_hashmap_mem): Return false, leaving
     the hashmap unchanged, when the shared memory is exhausted.  Free the
     old table with its size in bytes.
     (resize_hm): Return false and restore the old table on failure.
     Free the old table with its size in bytes.
     (hashmap_set): Return false when the hashmap cannot be enlarged.
     * caf/shmem/hashmap.h (hashmap_set): Return bool.

gcc/testsuite/ChangeLog:

     * gfortran.dg/coarray/alloc_pool_exhausted_3.f90: New test.
---

Reply via email to