Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segfault in vlen io API test #4130

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions test/API/H5_api_dataset_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -9853,6 +9853,9 @@ test_dataset_vlen_io(void)
hvl_t wbuf[DATASET_VLEN_IO_DSET_DIMS];
hvl_t rbuf[DATASET_VLEN_IO_DSET_DIMS];

memset(wbuf, 0, sizeof(hvl_t) * DATASET_VLEN_IO_DSET_DIMS);
memset(rbuf, 0, sizeof(hvl_t) * DATASET_VLEN_IO_DSET_DIMS);

TESTING_MULTIPART(
"verification of dataset data with H5Dwrite and then H5D read with variable length sequence data");

Expand Down Expand Up @@ -10001,7 +10004,7 @@ test_dataset_vlen_io(void)
if ((file_id = H5Fopen(H5_api_test_filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
PART_TEST_ERROR(rw_all_int);

if ((container_group = H5Gopen(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0)
if ((container_group = H5Gopen2(file_id, DATASET_TEST_GROUP_NAME, H5P_DEFAULT)) < 0)
PART_TEST_ERROR(rw_all_int);

if ((dset_int = H5Dopen2(container_group, DATASET_VLEN_IO_DSET_NAME "_int", H5P_DEFAULT)) < 0)
Expand Down Expand Up @@ -10218,6 +10221,7 @@ test_dataset_vlen_io(void)

PART_BEGIN(rw_point_selection)
{
TESTING_2("write with point selection");
/* Select even-indexed points */
for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS / 2; i++)
point_coords[i] = i * 2;
Expand Down Expand Up @@ -10315,6 +10319,7 @@ test_dataset_vlen_io(void)

PART_BEGIN(rw_hyperslab_selection)
{
TESTING_2("write with hyperslab selection");
/* Select hyperslab of every 3rd element */
const hsize_t start[1] = {0};
const hsize_t stride[1] = {3};
Expand Down Expand Up @@ -10422,6 +10427,7 @@ test_dataset_vlen_io(void)
TEST_ERROR;
if (H5Sclose(space_id) < 0)
TEST_ERROR;

/* In case of memory allocation error, not all hvl_t buffers in array may be allocated.
* Free one-by-one */
for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) {
Expand Down Expand Up @@ -10453,9 +10459,12 @@ test_dataset_vlen_io(void)
{
H5Fclose(file_id);
H5Gclose(container_group);
H5Dclose(dset_int);
H5Dclose(dset_float);
H5Dclose(dset_string);
if (dset_int != H5I_INVALID_HID)
H5Dclose(dset_int);
if (dset_float != H5I_INVALID_HID)
H5Dclose(dset_float);
if (dset_string != H5I_INVALID_HID)
H5Dclose(dset_string);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these IDs were initialized to H5I_INVALID_HID and the purpose of the BEGIN_TRY and END_TRY blocks is to hide any errors while we try to close anything not yet closed while possibly closing stuff that IS closed, you shouldn't need to check for H5I_INVALID_HID here. That said, it doesn't hurt anything.

H5Sclose(space_id);
for (size_t i = 0; i < DATASET_VLEN_IO_DSET_DIMS; i++) {
if (wbuf[i].p) {
Expand Down
Loading