Skip to content

H5Pget_driver_info: do not push an error when the driver has no info block - #6652

Open
hyoklee wants to merge 5 commits into
HDFGroup:developfrom
hyoklee:fix/pget-driver-info-spurious-error
Open

hyoklee wants to merge 5 commits into
HDFGroup:developfrom
hyoklee:fix/pget-driver-info-spurious-error

Conversation

@hyoklee

@hyoklee hyoklee commented Aug 29, 2026

Copy link
Copy Markdown
Member

Fixes #6651.

H5Pget_driver_info() pushed H5E_CANTGET whenever H5P_peek_driver_info() returned NULL. NULL is not necessarily a failure there: a driver that registered no driver-specific properties leaves driver_info NULL, which is exactly what H5Pset_driver_by_name() and the HDF5_DRIVER environment variable produce.

Both the function's own header comment and its entry in H5Ppublic.h say that case returns NULL with no error pushed:

Failure: NULL. Null is also returned if the driver has not registered any driver-specific properties although no error is pushed on the stack in this case.

and

If no driver-specific properties have been registered, H5Pget_driver_info() returns NULL.

The sibling H5Pget_driver_config_str() already handles the same situation correctly:

    if ((config_str = H5P_peek_driver_config_str(plist))) {

Effect

Any VFD that fetches its optional FAPL info block — including HDF5's own H5FDmulti.c, in four places — prints an HDF5-DIAG stack on every open describing an error that did not occur:

HDF5-DIAG: Error detected in HDF5 (2.3.0):
  #000: src/H5Pfapl.c line 1546 in H5Pget_driver_info(): can't get driver info
    major: Property lists
    minor: Can't get value

I hit this running the netCDF-C test suite over an out-of-tree VFD selected with HDF5_DRIVER=<name>: every H5Fopen in the run produced one of these. Harmless to the operation, but not to testing — any test comparing a program's stderr against a reference sees a diff, and someone reading the output of a driver under development is told there is an error when there is not.

The change

Drop the wrapper HGOTO_ERROR and assign the result. Nothing that was diagnosed stops being diagnosed: H5P_peek_driver_info() pushes H5E_BADTYPE itself for a list that is not a file access property list, and H5E_CANTGET when the property cannot be read. The removed frame only ever duplicated one of those or fired on a normal NULL.

Not a recent regression — the code dates to at least [svn-r15510] (2008).

🤖 Generated with Claude Code

H5Pget_driver_info() pushed H5E_CANTGET whenever H5P_peek_driver_info()
returned NULL. NULL is not necessarily a failure there: a driver that
registered no driver-specific properties leaves driver_info NULL, which is
what H5Pset_driver_by_name() and the HDF5_DRIVER environment variable both
produce.

Both the function's own header comment and its entry in H5Ppublic.h say
that case returns NULL with no error pushed:

    Failure:    NULL. Null is also returned if the driver has
            not registered any driver-specific properties
            although no error is pushed on the stack in
            this case.

The sibling H5Pget_driver_config_str() already handles the same situation
correctly. The effect of the mismatch is that any VFD which fetches its
optional FAPL info block -- including HDF5's own H5FDmulti.c, in four
places -- prints an HDF5-DIAG stack on every open describing an error that
did not occur.

The two genuine failures still report themselves: H5P_peek_driver_info()
pushes H5E_BADTYPE for a list that is not a file access property list, and
H5E_CANTGET when the property cannot be read. The removed frame only ever
duplicated those or fired on a normal NULL.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Review Checklist

This PR touches the following areas. Each needs a sign-off
from its listed owners before merging.

  • src
    • @fortnern (manually added) — approval required

@hyoklee

hyoklee commented Aug 29, 2026

Copy link
Copy Markdown
Member Author

Verified with a minimal reproducer. H5Pset_driver_by_name(fapl, "sec2", NULL) is what HDF5_DRIVER=sec2 does internally and sets no driver-info block, so driver_info is legitimately NULL:

if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) return 1;
if (H5Pset_driver_by_name(fapl, "sec2", NULL) < 0) return 1;

info  = H5Pget_driver_info(fapl);
nerrs = H5Eget_num(H5E_DEFAULT);

Before, on develop @ b7b85e7abf9, Windows 11 / MSVC 19.x:

HDF5-DIAG: Error detected in HDF5 (2.3.0):
  #000: src\H5Pfapl.c line 1546 in H5Pget_driver_info(): can't get driver info
    major: Property lists
    minor: Can't get value
driver_info = NULL (no info block)
errors on the stack after the call = 1

After:

driver_info = NULL (no info block)
errors on the stack after the call = 0

Same return value, and the stack is now clean — which is what the documented contract says should have been happening all along.

hyoklee added a commit to hyoklee/hdf5 that referenced this pull request Aug 29, 2026
H5Pget_driver_info() pushed H5E_CANTGET whenever H5P_peek_driver_info()
returned NULL, which is a normal return when the driver registered no
driver-specific properties -- what H5Pset_driver_by_name() and the
HDF5_DRIVER environment variable both produce. Both the function's own
header comment and its entry in H5Ppublic.h document that case as
returning NULL with nothing pushed.

Clean merge; also picks up the two upstream develop commits the fork did
not have. HDFGroup#6652.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@nbagha1 nbagha1 added this to the HDF5 2.x.x milestone Sep 11, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To be triaged

Development

Successfully merging this pull request may close these issues.

H5Pget_driver_info() pushes an error when the driver has no info block, contrary to its documented contract

2 participants