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 two assertion failures in hyperslab code #5355

Merged
merged 1 commit into from
Mar 7, 2025

Conversation

jhendersonHDF
Copy link
Collaborator

No description provided.

@jhendersonHDF jhendersonHDF added Priority - 3. Low 🔽 Code cleanup, small feature change requests, etc. Component - C Library Core C library issues (usually in the src directory) Type - Bug / Bugfix Please report security issues to help@hdfgroup.org instead of creating an issue on GitHub labels Mar 6, 2025
@jhendersonHDF jhendersonHDF force-pushed the hyper_span_copy_bug branch 2 times, most recently from 2e9c39d to d9591a8 Compare March 6, 2025 00:26
@jhendersonHDF jhendersonHDF marked this pull request as draft March 6, 2025 01:12

FUNC_ENTER_NOAPI(FAIL)

/* Check args */
assert(dst);
assert(src);

/* Release the current selection */
if (H5S_SELECT_RELEASE(dst) < 0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Part of this PR was fixing H5Scopy() to return failure for datasets with a NULL extent (rank value of 0). However, the previous code didn't really account for failure and would release the selection in the destination space before determining if the selection copy portion actually succeeded or not. This could result in segfaults later on when the application tries to close the destination dataspace. This reworks things so the copy is made into a temporary dataspace and only releases the selection in the destination dataspace once things have succeeded.

@@ -3215,11 +3217,11 @@ H5S__hyper_copy(H5S_t *dst, const H5S_t *src, bool share_selection)
assert(dst);

/* Allocate space for the hyperslab selection information */
if (NULL == (dst->select.sel_info.hslab = H5FL_MALLOC(H5S_hyper_sel_t)))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The code here and below was directly manipulating the destination dataspace, which could leave things in a bad state if failure occurs. This function had to be reworked to use the local dst_hslab and only manipulate the destination dataspace after things have succeeded.

/* Copy the hyperslab span information */
dst->select.sel_info.hslab->span_lst =
H5S__hyper_copy_span(src->select.sel_info.hslab->span_lst, src->extent.rank);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Code wasn't previously checking for errors here, which would hide problems when trying to copy a dataspace with an extent of 0 dims.

@jhendersonHDF jhendersonHDF marked this pull request as ready for review March 6, 2025 02:11
@lrknox lrknox merged commit 5e32f15 into HDFGroup:develop Mar 7, 2025
77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - C Library Core C library issues (usually in the src directory) Priority - 3. Low 🔽 Code cleanup, small feature change requests, etc. Type - Bug / Bugfix Please report security issues to help@hdfgroup.org instead of creating an issue on GitHub
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants