GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/libgomp

Libgomp test ensures unique filenames with many threads

A libgomp Fortran test now uses a larger buffer to correctly handle I/O unit numbers with more digits, preventing filename collisions in multi-threaded environ…

The libgomp.fortran/rwlock_1.f90 test in GCC’s OpenMP library now uses an enlarged buffer for file_name to accommodate 5-digit I/O unit numbers, up from 3 digits. This change addresses a potential issue where, with many threads, the generated temporary filenames for I/O operations could collide due to truncated unit numbers, leading to test failures or incorrect behavior in libgomp environments.

In Details

The change in libgomp.fortran/rwlock_1.f90 is a testsuite fix for a PR related to file I/O unit numbering. Specifically, it involves increasing the buffer size for file_name to correctly format unit numbers up to 5 digits, addressing the scenario where fortran I/O unit numbers (often 3-digit by default, but potentially larger in multi-threaded contexts) could cause collisions during temporary file creation. This ensures that when many OpenMP threads simultaneously perform I/O operations requiring unique temporary files, the filenames are indeed unique, especially on systems with a hig…

For Context

When a computer program, especially one using many 'threads' (mini-programs running at the same time), needs to create temporary files for its operations, it often generates unique names for these files. This helps prevent different threads from accidentally writing over each other's data. The libgomp library, which is part of GCC, helps programs use OpenMP to run tasks in parallel. This commit fixes a specific issue in a test for libgomp where, under heavy load (many threads), the system might try to create more than 999 temporary files. The old system for naming these files only had space for 3-digit identifiers, meaning files past 999 would get the same name and clash. The fix simply makes the naming system anticipate larger numbers, allowing for up to 5-digit identifiers and preventing these filename collisions.

Filed Under: libgompfortrantestingconcurrency