Skip to content

java.io.IOException: Invalid argument when opening file created by h5py #460

@frankier

Description

@frankier

I am having problems reading HDF5 file created by h5py. Here's the file: https://easyupload.io/4u3wc2 (unfortunately this link expires in 30 days -- I can reupload/resend on request).

Say I try to read it in Java (openjdk 14.0.2 2020-07-14 on Debian buster):

    try {
      System.out.println("path/to/file.h5");
      this.hdfFile = NetcdfFiles.open(path.toString());
    } catch (IOException e) {
      throw new UncheckedIOException(e);
    }

Using ucar.nc2.NetcdfFiles obtained using this in my build.gradle: compile group: "edu.ucar", name: "cdm-core", version: "5.3.3"

I get a stack trace like so:

Exception in thread "main" java.io.UncheckedIOException: java.io.IOException: java.io.IOException: Invalid argument
*SNIP*
Caused by: java.io.IOException: java.io.IOException: Invalid argument
    at ucar.nc2.NetcdfFiles.open(NetcdfFiles.java:282)
    at ucar.nc2.NetcdfFiles.open(NetcdfFiles.java:243)
    at ucar.nc2.NetcdfFiles.open(NetcdfFiles.java:228)
    at ucar.nc2.NetcdfFiles.open(NetcdfFiles.java:216)
    at org.vitrivr.cineast.core.util.pose.PreEmbeddingReader.<init>(PreEmbeddingReader.java:17)
    ... 19 more
Caused by: java.io.IOException: Invalid argument
    at java.base/java.io.RandomAccessFile.seek0(Native Method)
    at java.base/java.io.RandomAccessFile.seek(RandomAccessFile.java:593)
    at ucar.unidata.io.RandomAccessFile.read_(RandomAccessFile.java:743)
    at ucar.unidata.io.RandomAccessFile.readBuffer(RandomAccessFile.java:505)
    at ucar.unidata.io.RandomAccessFile.seek(RandomAccessFile.java:493)
    at ucar.nc2.iosp.hdf5.FractalHeap.readIndirectBlock(FractalHeap.java:453)
    at ucar.nc2.iosp.hdf5.FractalHeap.readIndirectBlock(FractalHeap.java:517)
    at ucar.nc2.iosp.hdf5.FractalHeap.<init>(FractalHeap.java:192)
    at ucar.nc2.internal.iosp.hdf5.H5objects.readGroupNew(H5objects.java:2102)
    at ucar.nc2.internal.iosp.hdf5.H5objects.access$700(H5objects.java:26)
    at ucar.nc2.internal.iosp.hdf5.H5objects$H5Group.<init>(H5objects.java:196)
    at ucar.nc2.internal.iosp.hdf5.H5objects$H5Group.<init>(H5objects.java:154)
    at ucar.nc2.internal.iosp.hdf5.H5objects.readRootSymbolTable(H5objects.java:58)
    at ucar.nc2.internal.iosp.hdf5.H5headerNew.readSuperBlock1(H5headerNew.java:350)
    at ucar.nc2.internal.iosp.hdf5.H5headerNew.read(H5headerNew.java:246)
    at ucar.nc2.internal.iosp.hdf5.H5iospNew.build(H5iospNew.java:119)
    at ucar.nc2.NetcdfFiles.build(NetcdfFiles.java:787)
    at ucar.nc2.NetcdfFiles.open(NetcdfFiles.java:726)
    at ucar.nc2.NetcdfFiles.open(NetcdfFiles.java:279)
    ... 23 more

This is odd since ncdump dumps it just fine (netcdf library version 4.7.4 of Apr 21 2020 19:56:21).
If I check in a debugger I see that this happens when FractalHeap.java tries to seek to 4776428346306319609 which is quite far beyond the end of the file(!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions