Thomas Koenig e32c3fb431 Generate a runtime error on recursive I/O, thread-safe
This patch is a version of Jerry's patch with one additional feature.
When locking a unit, the thread ID of the locking thread also stored
in the gfc_unit structure. When the unit is found to be locked, it can
be either have been locked by the same thread (bad, recursive I/O) or
by another thread (harmless).

Regression-tested fully (make -j8 check in the gcc build directory) on
Linux, which links in pthreads by default.  Steve checked on FreeBSD,
which does not do so.

Jerry DeLisle  <jvdelisle@gcc.gnu.org>
Thomas Koenig <tkoenig@gcc.gnu.org>

PR libfortran/119136

gcc/fortran/ChangeLog:

	* libgfortran.h: Add enum for new LIBERROR_RECURSIVE_IO.

libgfortran/ChangeLog:

	* io/async.h (UNLOCK_UNIT): New macro.
	(TRYLOCK_UNIT): New macro.
	(LOCK_UNIT): New macro.
	* io/io.h: Delete prototype for unused stash_internal_unit.
	(check_for_recursive): Add prototype for this new function.
	* io/transfer.c (data_transfer_init): Add call to new
	check_for_recursive.
	* io/unit.c (delete_unit): Fix comment.
	(check_for_recursive): Add new function.
	(init_units): Use new macros.
	(close_unit_1): Likewise.
	(unlock_unit): Likewise.
	* io/unix.c (flush_all_units_1): Likewise.
	(flush_all_units): Likewise.
	* runtime/error.c (translate_error): : Add translation for
	"Recursive I/O not allowed runtime error message.

gcc/testsuite/ChangeLog:

	* gfortran.dg/pr119136.f90: New test.
2026-01-06 07:32:10 +01:00
2026-01-02 09:56:11 +01:00
2025-12-31 00:16:24 +00:00
2026-01-03 00:16:36 +00:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-02 10:47:06 +01:00
2026-01-02 09:56:11 +01:00
2026-01-06 00:16:27 +00:00
2026-01-02 09:56:11 +01:00
2025-12-30 00:16:33 +00:00
2026-01-03 00:16:36 +00:00
2026-01-02 09:56:11 +01:00
2025-12-30 00:16:33 +00:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-02 10:47:06 +01:00
2026-01-02 00:16:23 +00:00
2025-12-30 00:16:33 +00:00
2026-01-02 09:56:11 +01:00
2026-01-02 10:47:06 +01:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2025-12-22 00:16:25 +00:00
2025-12-30 00:16:33 +00:00
2026-01-06 00:16:27 +00:00
2025-11-30 01:52:24 +01:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 4.2 GiB
Languages
C++ 30.7%
C 30.2%
Ada 14.4%
D 6.1%
Go 5.7%
Other 12.4%