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

Fixes a segfault when H5Pset_mdc_log_options is called multiple times on a fapl #601

Merged
merged 28 commits into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ba9deae
Committing clang-format changes
github-actions[bot] Mar 19, 2021
00f9750
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 21, 2021
e997283
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 22, 2021
3eac585
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 23, 2021
71643b7
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 24, 2021
d242911
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 24, 2021
bc70f95
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 26, 2021
3d7ad8e
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 26, 2021
aeb16b7
Merge branch 'develop' of https://github.com/derobins/hdf5 into develop
derobins Mar 26, 2021
765cb5b
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 27, 2021
18401fc
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 29, 2021
222242c
Merge branch 'develop' of https://github.com/derobins/hdf5 into develop
derobins Mar 29, 2021
8d0cafa
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 30, 2021
d3694d1
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 2, 2021
1c7bcc2
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 15, 2021
70551e3
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 16, 2021
2dfc7db
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 20, 2021
71d2fbf
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 21, 2021
c8925f8
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 22, 2021
dd3e970
Merge branch 'develop' of https://github.com/derobins/hdf5 into develop
derobins Apr 22, 2021
bb61990
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 23, 2021
2c2b368
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 25, 2021
be2ada6
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 27, 2021
568fea5
Fixes a segfault when H5Pset_mdc_log_options() is called multiple times
derobins Apr 28, 2021
3b5d2b8
Fixes typos
derobins Apr 28, 2021
439f3a8
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 28, 2021
649aa9b
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 29, 2021
8403c6f
Merge branch 'develop' into minor/H5Pset_mdc_log_options_2x_fix
derobins Apr 29, 2021
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
12 changes: 12 additions & 0 deletions release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,18 @@ New Features

(DER - 2021/04/28, HDFFV-11240)

- Fixes a segfault when H5Pset_mdc_log_options() is called multiple times

The call incorrectly attempts to free an internal copy of the previous
log location string, which causes a segfault. This only happens
when the call is invoked multiple times on the same property list.
On the first call to a given fapl, the log location is set to NULL so
the segfault does not occur.

The string is now handled properly and the segfault no longer occurs.

(DER - 2021/04/27, HDFFV-11239)

- HSYS_GOTO_ERROR now emits the results of GetLastError() on Windows

HSYS_GOTO_ERROR is an internal macro that is used to produce error
Expand Down
11 changes: 3 additions & 8 deletions src/H5Pfapl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4221,7 +4221,7 @@ herr_t
H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const char *location, hbool_t start_on_access)
{
H5P_genplist_t *plist; /* Property list pointer */
char * tmp_location; /* Working location pointer */
char * new_location; /* Working location pointer */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
Expand All @@ -4237,19 +4237,14 @@ H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const char *location,
if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "plist_id is not a file access property list")

/* Get the current location string and free it */
if (H5P_get(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &tmp_location) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current log location")
H5MM_xfree(tmp_location);

/* Make a copy of the passed-in location */
if (NULL == (tmp_location = H5MM_xstrdup(location)))
if (NULL == (new_location = H5MM_xstrdup(location)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy passed-in log location")

/* Set values */
if (H5P_set(plist, H5F_ACS_USE_MDC_LOGGING_NAME, &is_enabled) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set is_enabled flag")
if (H5P_set(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &tmp_location) < 0)
if (H5P_set(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &new_location) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set log location")
if (H5P_set(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, &start_on_access) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set start_on_access flag")
Expand Down
6 changes: 6 additions & 0 deletions test/cache_logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ test_logging_api(void)
if (H5Pset_mdc_log_options(fapl, is_enabled, LOG_LOCATION, start_on_access) < 0)
TEST_ERROR;

/* Ensure that setting the property twice doesn't cause problems
* (addresses a previous bug).
*/
if (H5Pset_mdc_log_options(fapl, is_enabled, LOG_LOCATION, start_on_access) < 0)
TEST_ERROR;

/* Check to make sure that the property list getter returns the correct
* location string buffer size;
*/
Expand Down