Skip to content

Commit 5e03b3a

Browse files
authored
Change default file format to 1.8 (#5949)
Change default file format to 1.8 across various tests and examples, updating file creation and access logic accordingly. Behavior: Default file format version changed to 1.8 in H5Pfapl.c. Updated file creation and access to use 1.8 format in h5ex_g_compact.c and test_file_image.c. Set earliest file format in multiple test files including cache_tagging.c, dtypes.c, and links.c. Tests: Modified expected output in tools/test/misc/expected/*.ls files to reflect new file format locations. Adjusted test logic in test_file_image.c and cache_tagging.c to accommodate format changes. Misc: Added comments and TODOs for future format testing in test_file_image.c. Minor variable renaming for clarity in test_file_image.c.
1 parent 42588ae commit 5e03b3a

32 files changed

+371
-124
lines changed

HDF5Examples/C/H5G/h5ex_g_compact.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,17 @@ main(void)
2828
H5G_info_t ginfo;
2929
hsize_t size;
3030

31+
/*
32+
* Set file access property list to use the earliest file format.
33+
* This will force the library to create original format groups.
34+
*/
35+
fapl = H5Pcreate(H5P_FILE_ACCESS);
36+
status = H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST);
37+
3138
/*
3239
* Create file 1. This file will use original format groups.
3340
*/
34-
file = H5Fcreate(FILENAME1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
41+
file = H5Fcreate(FILENAME1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
3542
group = H5Gcreate(file, GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
3643

3744
/*
@@ -72,16 +79,16 @@ main(void)
7279
status = H5Fclose(file);
7380

7481
/*
75-
* Set file access property list to allow the latest file format.
76-
* This will allow the library to create new compact format groups.
82+
* Now use the default file access property list to allow the latest file
83+
* format. This will allow the library to create new compact format groups.
84+
* Since HDF5 2.0, the default is to use the 1.8 file format as the low
85+
* bound, which includes compact groups.
7786
*/
78-
fapl = H5Pcreate(H5P_FILE_ACCESS);
79-
status = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
8087

8188
/*
82-
* Create file 2 using the new file access property list.
89+
* Create file 2 using the default access property list.
8390
*/
84-
file = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
91+
file = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
8592
group = H5Gcreate(file, GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
8693

8794
/*

c++/test/tfile.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ test_file_create()
8080
H5File *file1 = NULL;
8181
try {
8282
// Create file FILE1
83-
file1 = new H5File(FILE1, H5F_ACC_EXCL);
83+
file1 = new H5File(FILE1, H5F_ACC_TRUNC);
8484

8585
// Try to create the same file with H5F_ACC_TRUNC. This should fail
8686
// because file1 is the same file and is currently open.
@@ -847,8 +847,10 @@ test_file_info()
847847
H5F_fspace_strategy_t out_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR;
848848

849849
try {
850-
// Create a file using default properties.
851-
H5File tempfile(FILE7, H5F_ACC_TRUNC);
850+
// Create a file using the earliest format.
851+
FileAccPropList fapl;
852+
fapl.setLibverBounds(H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST);
853+
H5File tempfile(FILE7, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
852854

853855
// Get the file's version information.
854856
H5F_info2_t finfo;

c++/test/tlinks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ test_visit(hid_t fapl_id, bool new_format)
666666
delete file;
667667

668668
// Reopen the file and group in the file.
669-
file = new H5File(filename, H5F_ACC_RDWR);
669+
file = new H5File(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl);
670670
group = new Group(file->openGroup("Data"));
671671

672672
// Open the group

fortran/test/tH5F.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ SUBROUTINE file_space(filename, cleanup, total_error)
11451145

11461146
CALL h5fget_freespace_f(fid, free_space, error)
11471147
CALL check("h5fget_freespace_f",error,total_error)
1148-
IF(error .EQ.0 .AND. free_space .NE. 1248) THEN
1148+
IF(error .EQ.0 .AND. free_space .NE. 1853) THEN
11491149
total_error = total_error + 1
11501150
WRITE(*,*) "1: Wrong amount of free space reported, ", free_space
11511151
ENDIF
@@ -1161,7 +1161,7 @@ SUBROUTINE file_space(filename, cleanup, total_error)
11611161
! Check the free space now
11621162
CALL h5fget_freespace_f(fid, free_space, error)
11631163
CALL check("h5fget_freespace_f",error,total_error)
1164-
IF(error .EQ.0 .AND. free_space .NE. 216) THEN
1164+
IF(error .EQ.0 .AND. free_space .NE. 1706) THEN
11651165
total_error = total_error + 1
11661166
WRITE(*,*) "2: Wrong amount of free space reported, ", free_space
11671167
ENDIF
@@ -1173,7 +1173,7 @@ SUBROUTINE file_space(filename, cleanup, total_error)
11731173
! Check the free space now
11741174
CALL h5fget_freespace_f(fid, free_space, error)
11751175
CALL check("h5fget_freespace_f",error,total_error)
1176-
IF(error .EQ.0 .AND. free_space .NE. 1248) THEN
1176+
IF(error .EQ.0 .AND. free_space .NE. 1853) THEN
11771177
total_error = total_error + 1
11781178
WRITE(*,*) "3: Wrong amount of free space reported, ", free_space
11791179
ENDIF

hl/test/test_file_image.c

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@
5252
static int
5353
test_file_image(size_t open_images, size_t nflags, const unsigned *flags)
5454
{
55-
hid_t *file_id = NULL, *dset_id = NULL, file_space, plist; /* HDF5 ids */
56-
hsize_t dims1[RANK] = {2, 3}; /* original dimension of datasets */
55+
hid_t *file_id = NULL; /* Array of file IDs */
56+
hid_t *dset_id = NULL; /* Array of dataset IDs */
57+
hid_t file_space_id = H5I_INVALID_HID; /* Dataspace ID */
58+
hid_t dcpl_id = H5I_INVALID_HID; /* DCPL ID */
59+
hid_t fapl_id = H5I_INVALID_HID; /* FAPL ID */
60+
hsize_t dims1[RANK] = {2, 3}; /* original dimension of datasets */
5761
hsize_t max_dims[RANK] = {H5S_UNLIMITED, H5S_UNLIMITED};
5862
int data1[6] = {1, 2, 3, 4, 5, 6}; /* original contents of dataset */
5963
int data2[6] = {7, 8, 9, 10, 11, 12}; /* "wrong" contents of dataset */
@@ -99,6 +103,13 @@ test_file_image(size_t open_images, size_t nflags, const unsigned *flags)
99103
if (NULL == (dset_id = (hid_t *)malloc(sizeof(hid_t) * open_images)))
100104
FAIL_PUTS_ERROR("malloc() failed");
101105

106+
/* Create FAPL and set earliest format */
107+
/* TODO: run this test with all different formats */
108+
if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0)
109+
FAIL_PUTS_ERROR("H5Pcreate() failed");
110+
if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0)
111+
FAIL_PUTS_ERROR("H5Pset_libver_bounds() failed");
112+
102113
HL_TESTING2("get file images");
103114

104115
/* create several file images */
@@ -117,24 +128,24 @@ test_file_image(size_t open_images, size_t nflags, const unsigned *flags)
117128
snprintf(filename[i], filenamelength, "image_file%d.h5", (int)i);
118129

119130
/* create file */
120-
if ((file_id[i] = H5Fcreate(filename[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
131+
if ((file_id[i] = H5Fcreate(filename[i], H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0)
121132
FAIL_PUTS_ERROR("H5Fcreate() failed");
122133

123134
/* define dataspace for the dataset */
124-
if ((file_space = H5Screate_simple(RANK, dims1, max_dims)) < 0)
135+
if ((file_space_id = H5Screate_simple(RANK, dims1, max_dims)) < 0)
125136
FAIL_PUTS_ERROR("H5Screate_simple() failed");
126137

127138
/* create dataset property list */
128-
if ((plist = H5Pcreate(H5P_DATASET_CREATE)) < 0)
139+
if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
129140
FAIL_PUTS_ERROR("H5Pcreate() failed");
130141

131142
/* set property list to create chunked dataset */
132-
if (H5Pset_chunk(plist, RANK, dims1) < 0)
143+
if (H5Pset_chunk(dcpl_id, RANK, dims1) < 0)
133144
FAIL_PUTS_ERROR("H5Pset_chunk() failed");
134145

135146
/* create and write an integer type dataset named "dset" */
136-
if ((dset_id[i] = H5Dcreate2(file_id[i], DSET_NAME, H5T_NATIVE_INT, file_space, H5P_DEFAULT, plist,
137-
H5P_DEFAULT)) < 0)
147+
if ((dset_id[i] = H5Dcreate2(file_id[i], DSET_NAME, H5T_NATIVE_INT, file_space_id, H5P_DEFAULT,
148+
dcpl_id, H5P_DEFAULT)) < 0)
138149
FAIL_PUTS_ERROR("H5Dcreate() failed");
139150

140151
/* dataset in open image 1 is written with "wrong" data */
@@ -153,11 +164,11 @@ test_file_image(size_t open_images, size_t nflags, const unsigned *flags)
153164
FAIL_PUTS_ERROR("H5Fflush() failed");
154165

155166
/* close dataset property list */
156-
if (H5Pclose(plist) < 0)
167+
if (H5Pclose(dcpl_id) < 0)
157168
FAIL_PUTS_ERROR("H5Pclose() failed");
158169

159170
/* close dataspace */
160-
if (H5Sclose(file_space) < 0)
171+
if (H5Sclose(file_space_id) < 0)
161172
FAIL_PUTS_ERROR("H5Sclose() failed");
162173

163174
/* close dataset */
@@ -277,11 +288,11 @@ test_file_image(size_t open_images, size_t nflags, const unsigned *flags)
277288
FAIL_PUTS_ERROR("H5Dopen() failed");
278289

279290
/* get dataspace for the dataset */
280-
if ((file_space = H5Dget_space(dset_id[i])) < 0)
291+
if ((file_space_id = H5Dget_space(dset_id[i])) < 0)
281292
FAIL_PUTS_ERROR("H5Dget_space() failed");
282293

283294
/* get dimensions for the dataset */
284-
if (H5Sget_simple_extent_dims(file_space, dims3, NULL) < 0)
295+
if (H5Sget_simple_extent_dims(file_space_id, dims3, NULL) < 0)
285296
FAIL_PUTS_ERROR("H5Sget_simple_extent_dims() failed");
286297

287298
/* read dataset */
@@ -312,7 +323,7 @@ test_file_image(size_t open_images, size_t nflags, const unsigned *flags)
312323
} /* end else */
313324

314325
/* close dataspace */
315-
if (H5Sclose(file_space) < 0)
326+
if (H5Sclose(file_space_id) < 0)
316327
FAIL_PUTS_ERROR("H5Sclose() failed");
317328
} /* end for */
318329

@@ -455,11 +466,11 @@ test_file_image(size_t open_images, size_t nflags, const unsigned *flags)
455466
FAIL_PUTS_ERROR("H5Dopen() failed");
456467

457468
/* get dataspace for the dataset */
458-
if ((file_space = H5Dget_space(dset_id[i])) < 0)
469+
if ((file_space_id = H5Dget_space(dset_id[i])) < 0)
459470
FAIL_PUTS_ERROR("H5Dget_space() failed");
460471

461472
/* get dimensions for the dataset */
462-
if (H5Sget_simple_extent_dims(file_space, dims3, NULL) < 0)
473+
if (H5Sget_simple_extent_dims(file_space_id, dims3, NULL) < 0)
463474
FAIL_PUTS_ERROR("H5Sget_simple_extent_dims() failed");
464475

465476
/* read dataset */
@@ -479,7 +490,7 @@ test_file_image(size_t open_images, size_t nflags, const unsigned *flags)
479490
FAIL_PUTS_ERROR("comparison of image values with original data failed");
480491

481492
/* close dataspace */
482-
if (H5Sclose(file_space) < 0)
493+
if (H5Sclose(file_space_id) < 0)
483494
FAIL_PUTS_ERROR("H5Sclose() failed");
484495

485496
/* close dataset */
@@ -513,6 +524,10 @@ test_file_image(size_t open_images, size_t nflags, const unsigned *flags)
513524

514525
} /* end for */
515526

527+
/* close file access property list */
528+
if (H5Pclose(fapl_id) < 0)
529+
FAIL_PUTS_ERROR("H5Pclose() failed");
530+
516531
/* release temporary working buffers */
517532
for (i = 0; i < open_images; i++)
518533
free(filename[i]);

java/test/TestH5Fbasic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public void testH5Fget_mdc_size()
293293
catch (Throwable err) {
294294
fail("H5.H5Fget_mdc_size: " + err);
295295
}
296-
assertTrue("H5.H5Fget_mdc_size #:" + nentries, nentries == 4);
296+
assertTrue("H5.H5Fget_mdc_size #:" + nentries, nentries == 2);
297297
}
298298

299299
// TODO: test more cases of different cache sizes.

java/test/TestH5Fparams.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public void testH5Fget_info()
210210

211211
try {
212212
H5F_info2_t finfo = H5.H5Fget_info(fid);
213-
assertEquals(finfo.super_version, 0);
213+
assertEquals(finfo.super_version, 2);
214214
assertEquals(finfo.free_version, 0);
215215
assertEquals(finfo.sohm_version, 0);
216216
}

java/test/TestH5P.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ public void testH5P_userblock()
10381038

10391039
/* Get the file's version information */
10401040
H5F_info2_t finfo = H5.H5Fget_info(H5fid);
1041-
assertTrue("super block version: " + finfo.super_version, finfo.super_version == 0);
1041+
assertTrue("super block version: " + finfo.super_version, finfo.super_version == 2);
10421042
assertTrue("free-space manager version: " + finfo.free_version, finfo.free_version == 0);
10431043
assertTrue("shared object header version: " + finfo.sohm_version, finfo.sohm_version == 0);
10441044
H5.H5Pget_userblock(fcpl_id, size);
@@ -1074,7 +1074,7 @@ public void testH5P_sizes()
10741074

10751075
/* Get the file's version information */
10761076
H5F_info2_t finfo = H5.H5Fget_info(H5fid);
1077-
assertTrue("super block version: " + finfo.super_version, finfo.super_version == 0);
1077+
assertTrue("super block version: " + finfo.super_version, finfo.super_version == 2);
10781078
assertTrue("free-space manager version: " + finfo.free_version, finfo.free_version == 0);
10791079
assertTrue("shared object header version: " + finfo.sohm_version, finfo.sohm_version == 0);
10801080
H5.H5Pget_sizes(fcpl_id, size);
@@ -1111,7 +1111,7 @@ public void testH5P_sym_k()
11111111

11121112
/* Get the file's version information */
11131113
H5F_info2_t finfo = H5.H5Fget_info(H5fid);
1114-
assertTrue("super block version: " + finfo.super_version, finfo.super_version == 0);
1114+
assertTrue("super block version: " + finfo.super_version, finfo.super_version == 2);
11151115
assertTrue("free-space manager version: " + finfo.free_version, finfo.free_version == 0);
11161116
assertTrue("shared object header version: " + finfo.sohm_version, finfo.sohm_version == 0);
11171117
H5.H5Pget_sym_k(fcpl_id, size);
@@ -1148,7 +1148,7 @@ public void testH5P_istore_k()
11481148

11491149
/* Get the file's version information */
11501150
H5F_info2_t finfo = H5.H5Fget_info(H5fid);
1151-
assertTrue("super block version: " + finfo.super_version, finfo.super_version == 1);
1151+
assertTrue("super block version: " + finfo.super_version, finfo.super_version == 2);
11521152
assertTrue("free-space manager version: " + finfo.free_version, finfo.free_version == 0);
11531153
assertTrue("shared object header version: " + finfo.sohm_version, finfo.sohm_version == 0);
11541154
H5.H5Pget_istore_k(fcpl_id, size);

java/test/TestH5Pfapl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ public void testH5Pget_libver_bounds()
412412
}
413413
assertTrue("testH5Pget_libver_bounds", ret_val >= 0);
414414
// Check the Earliest Version if the library
415-
assertEquals(HDF5Constants.H5F_LIBVER_EARLIEST, libver[0]);
415+
assertEquals(HDF5Constants.H5F_LIBVER_V18, libver[0]);
416416
// Check the Latest Version if the library
417417
assertEquals(HDF5Constants.H5F_LIBVER_LATEST, libver[1]);
418418
}

release_docs/CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ For releases prior to version 2.0.0, please see the release.txt file and for mor
5151

5252
# ⚠️ Breaking Changes
5353

54+
### Updated default file format to 1.8
55+
56+
By default, HDF5 will now use the 1.8 file format (`H5F_LIBVER_V18`). This provides improved performance and space efficiency, particularly with groups and links. However, HDF5 library versions 1.6 and earlier will not be able to read files created with the default settings. The previous behavior can be restored using `H5Pset_libver_bounds(fapl_id, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST)`.
57+
5458
### Renamed the option: `HDF5_ENABLE_Z_LIB_SUPPORT`
5559

5660
The option has been renamed to `HDF5_ENABLE_ZLIB_SUPPORT` to be consistent with the naming of other options. Also, the option defaults to OFF. This requires the user to explicitly enable zlib support when configuring the library.
@@ -59,6 +63,10 @@ For releases prior to version 2.0.0, please see the release.txt file and for mor
5963

6064
CMake is now the build system available in HDF5 code. Version 3.26 or later is required. See the AutotoolsToCMakeOptions.md file for highlights of the CMake HDF5 install layout and CMake options to use in place of former Autotools options.
6165

66+
### Fixed problems with family driver and user block
67+
68+
When using a user block with the family driver, the driver would inappropriately subtract the user block size for each member file when calculating member EOAs. This could cause a failure when an address overflowed the calculated eoa. The driver would also add the user block size when returning the EOF. Modified the family driver to not consider the user block, as it is handled by the H5FD layer. The user block now spans the first X bytes of the family array, for example a 4 KiB user block with 3 KiB member size will take up the entire first member and the first 1 KiB of the second. This may cause compatibility issues with preexisting family files with user blocks, though the way it worked before was inconsistent if it worked at all.
69+
6270
# 🚀 New Features & Improvements
6371

6472
## Configuration
@@ -185,6 +193,10 @@ All other HDF5 library CMake options are prefixed with `HDF5_`
185193

186194
## Library
187195

196+
### Updated default file format to 1.8
197+
198+
By default, HDF5 will now use the 1.8 file format (`H5F_LIBVER_V18`). This provides improved performance and space efficiency, particularly with groups and links. This behavior can be overridden with `H5Pset_libver_bounds()`.
199+
188200
### Added predefined datatypes for bfloat16 data
189201

190202
Predefined datatypes have been added for little- and big-endian bfloat16 (https://en.wikipedia.org/wiki/Bfloat16_floating-point_format) data.
@@ -557,6 +569,10 @@ Added Fortran wrapper h5fdsubfiling_get_file_mapping_f() for the subfiling file
557569

558570
## Library
559571

572+
### Fixed problems with family driver and user block
573+
574+
When using a user block with the family driver, the driver would inappropriately subtract the user block size for each member file when calculating member EOAs. This could cause a failure when an address overflowed the calculated eoa. The driver would also add the user block size when returning the EOF. Modified the family driver to not consider the user block, as it is handled by the H5FD layer. The user block now spans the first X bytes of the family array, for example a 4 KiB user block with 3 KiB member size will take up the entire first member and the first 1 KiB of the second. This may cause compatibility issues with preexisting family files with user blocks, though the way it worked before was inconsistent if it worked at all.
575+
560576
### Fixed security issue CVE-2025-7067
561577

562578
Fixed a heap buffer overflow in H5FS__sinfo_serialize_node_cb() by discarding file free space sections from the file free space manager when they are found to be invalid. Specifically crafted HDF5 files can result in an attempt to insert duplicate or overlapping file free space sections into a file free space manager, later resulting in a buffer overflow when the same free space section is serialized to the file multiple times.

0 commit comments

Comments
 (0)