Fortran: Fix libgfortran I/O race with newunit_free [PR99529]
authorTobias Burnus <tobias@codesourcery.com>
Fri, 12 Mar 2021 15:31:32 +0000 (16:31 +0100)
committerTobias Burnus <tobias@codesourcery.com>
Fri, 12 Mar 2021 15:31:32 +0000 (16:31 +0100)
commita6e9633ccb593937fceec67fafc2afe5d518d735
tree1d356aacf223cd2702f38474e74191764f217cec
parent3bb345c9313ad8f6a6c24abd7d5eaa11413bbe22
Fortran: Fix libgfortran I/O race with newunit_free [PR99529]

libgfortran/ChangeLog:

* io/transfer.c (st_read_done_worker, st_write_done_worker):
Call unlock_unit here, add unit_lock lock around newunit_free call.
(st_read_done, st_write_done): Only call unlock_unit when not
calling the worker function.
* io/unit.c (set_internal_unit): Don't reset the unit_number
to the same number as this cause race warnings.
libgfortran/io/transfer.c
libgfortran/io/unit.c