From 2c2e39c72ff977a5d12a10f1a3276e7b8efa4dcd Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 15 May 2024 13:55:30 -0500 Subject: [PATCH] Disable EOF checks for SWMR readers in more cases. (#4489) 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. --- src/H5Fsuper.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 6eb465ed9d1..a4940d8b85b 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -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) {