Skip to content

Commit

Permalink
Disable EOF checks for SWMR readers in more cases. (HDFGroup#4489)
Browse files Browse the repository at this point in the history
Fixes a race condition where the reader opens the file and sets its EOF from the
file's size (from the stat() call in the driver open callback).  Then, before
the reader can read the file's superblock, a SWMR writer races in, extends the
file, and closes the file, writing an updated superblock with the 'writer' and
'SWMR writer' flags in the superblock off (appropriately).  Then the reader
proceeds to read the superblock, and flags the EOF as wrong.  Taking out the
check for the 'writer' and 'SWMR writer' flags will cause SWMR readers to avoid
flagging the file as incorrect.
  • Loading branch information
qkoziol authored May 15, 2024
1 parent 773d6f9 commit 2c2e39c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/H5Fsuper.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,13 +583,10 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, bool initial_read)

if (H5F_INTENT(f) & H5F_ACC_SWMR_READ) {
/*
* When the file is opened for SWMR read access, skip the check if:
* --the file is already marked for SWMR writing and
* --the file has version 3 superblock for SWMR support
* When the file is opened for SWMR read access, skip the check if
* the file has a version 3 superblock capable of SWMR support
*/
if ((sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS) &&
(sblock->status_flags & H5F_SUPER_WRITE_ACCESS) &&
sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3)
if (sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3)
skip_eof_check = true;
}
if (!skip_eof_check && initial_read) {
Expand Down

0 comments on commit 2c2e39c

Please sign in to comment.