Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

EOFException on NCDump data #1342

Closed
Mikhail-Aoun opened this issue Oct 22, 2020 · 0 comments · Fixed by #1343
Closed

EOFException on NCDump data #1342

Mikhail-Aoun opened this issue Oct 22, 2020 · 0 comments · Fixed by #1343

Comments

@Mikhail-Aoun
Copy link

Hi,
We've found an issue when trying to read data from some particular netcdf files. We met an EOFException in the ucar.nc2.iosp.hdf5.H5header$GlobalHeap instantiation algorithm.
The bug can be reproduced with ToolsUI latest maintenance release (Version 4.6.15) and this attached netcdf file as example :
SGA1-RO_-00-SRC_C_EUMT_20200704124757_G_O_20200704124200_20200704124459_O_N____.zip

When you open this file and try to NCDump tm_packets data, it will raise the following exception :

byte tm_packets(number_tm_packets=10256, *);
:long_name = "Array of TM packets";
:_Unsigned = "true";

data:
java.io.EOFException
at ucar.unidata.io.RandomAccessFile.readInt(RandomAccessFile.java:1244)
at ucar.unidata.io.RandomAccessFile.readLong(RandomAccessFile.java:1325)
at ucar.nc2.iosp.hdf5.H5header.readLength(H5header.java:4950)
at ucar.nc2.iosp.hdf5.H5header$GlobalHeap.(H5header.java:4772)
at ucar.nc2.iosp.hdf5.H5header$HeapIdentifier.getHeapObject(H5header.java:4688)
at ucar.nc2.iosp.hdf5.H5header.getHeapDataArray(H5header.java:4525)
at ucar.nc2.iosp.hdf5.H5header.getHeapDataArray(H5header.java:4519)
at ucar.nc2.iosp.hdf5.H5iosp.readData(H5iosp.java:285)
at ucar.nc2.iosp.hdf5.H5iosp.readData(H5iosp.java:206)
at ucar.nc2.iosp.hdf5.H5iosp.readData(H5iosp.java:144)
at ucar.nc2.NetcdfFile.readData(NetcdfFile.java:2026)
at ucar.nc2.Variable.reallyRead(Variable.java:874)
at ucar.nc2.Variable._read(Variable.java:845)
at ucar.nc2.Variable._read(Variable.java:886)
at ucar.nc2.Variable.read(Variable.java:709)
at ucar.nc2.NetcdfFile.readSection(NetcdfFile.java:2053)
at ucar.nc2.ui.NCdumpPane$NCdumpTask.run(NCdumpPane.java:286)
at java.lang.Thread.run(Unknown Source)

The data can be read with the netcdf-C or python library. If we regenerate the netcdf file with the netcdf-C library, the generated netcdfile (with exactly the same data) will work with the java library.

Analysis and correction :
The bug seems to be linked to the ucar.nc2.iosp.hdf5.H5header$GlobalHeap instantiation algorithm which doesn't handle correctly some particular file byte structures.
After debugging, we've managed to find a fix which work with our tests and ToolsUI. I will submit the associated Pull request.

This bug happens also with Tools UI latest stable release (Version 5.3.3). I will create the associated Issue and Pull request on the other repository (Unidata/netcdf-java).

Mikhail-Aoun pushed a commit to Mikhail-Aoun/thredds that referenced this issue Oct 22, 2020
…ter we met a HeapObject.id equals to 0. Otherwise, we could be at the end of the file and a EOFException will be raised. Addresses the github issue Unidata#1342.
lesserwhirls added a commit that referenced this issue Oct 23, 2020
…a_#1342

Fix for EOFException on NCDump data #1342
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants