Java runtime crash regression in hdf5-1.10.1

The example code, H5Ex_G_Traverse fails with a runtime crash when iterating through a file with nested group members. The crash appears to be the result of JNI code in the file h5lImp.c. There might be multiple issues, and this is the new JDK-1.10.1.

One cause of the crash appears to be the variable “visit_callback”, which is overwritten when recursion starts. When recursion completes, “visit_callback” will be pointing to the wrong callback method. In the case of H5Ex_G_Traverse, it will be pointing to an object that is no longer on the stack and presumably has no reference counts, so it may be garbage collected. There should probably be a more comprehensive iterator test added to the Java code.

Advice and feedback appreciated.

/bbaker

The attached patch removes references to the global variable “visit_callback” from the file h5lImp.c and replace it with a small structure on the stack. If this is the consensus approach, similar fixes are needed for iterators in h5a, h5d, h5o, and h5p, as well as removing unused references to “extern jobject visit_callback” from other c modules.

With this patch, the example program now handles iteration through nested groups.

hdf5-1.10.1-jni1.patch (3.2 KB)

Hi William,

I entered bug HDFFV-10536 for this issue.
Thank you for the patch!

-Barbara