GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libgfortran

libgfortran: Prevent waiting for terminated images in caf_shmem

Ensures that Fortran coarray operations do not indefinitely block when an image has terminated.

This commit improves the robustness of Fortran’s coarray shared memory implementation by preventing indefinite blocking on terminated images. When an image stops or fails, it now properly withdraws from team barriers. This allows other waiting images to proceed once barrier counts reach zero, avoiding deadlocks that previously occurred with synchronization statements like SYNC ALL.

In Details

This patch, part of the ongoing F2023 coarray conformance effort for libgfortran's caf_shmem, prevents deadlocks caused by terminated images. Previously, images executing STOP or FAIL IMAGE would remain in team barrier counts, causing subsequent SYNC ALL operations to block indefinitely. The fix introduces leave_teams to remove terminated images from all their team barriers before they exit. Additionally, it refines SYNC IMAGES to correctly handle table indexing when the image count changes due to termination.

For Context
Coarray Fortran (CAF)
An extension to the Fortran language that provides parallel programming capabilities through a syntax for accessing components of distributed memory arrays (called 'corray' components) on other images (processes).
image
In Coarray Fortran, an image represents an independent unit of execution, typically a process or thread, that can communicate with other images.
SYNC ALL
Coarray Fortran synchronization primitive. SYNC ALL synchronizes all images in the current team.
FAIL IMAGE
A Fortran coarray statement that initiates abnormal termination for a specific image.
team barrier
A synchronization point within a team of coarray images where all participating images must arrive before any can proceed.
Filed Under: libgfortrancoarrayfortrandeadlockbugfix