jamesmudd / jhdf

A pure Java HDF5 library
http://jhdf.io
MIT License
126 stars 35 forks source link

java.lang.ArithmeticException: Could not convert to unsigned #584

Open Apollo3zehn opened 1 week ago

Apollo3zehn commented 1 week ago

Describe the bug

I try to read chunked data which are encoded with the fixed-array indexing type and get the error java.lang.ArithmeticException: Could not convert to unsigned. Here is the full stack trace:

java.lang.ArithmeticException: Could not convert to unsigned
    at io.jhdf.Utils.readBytesAsUnsignedLong(Utils.java:204)
    at io.jhdf.dataset.chunked.indexing.FixedArrayIndex$FixedArrayDataBlock.<init>(FixedArrayIndex.java:122)
    at io.jhdf.dataset.chunked.indexing.FixedArrayIndex$FixedArrayDataBlock.<init>(FixedArrayIndex.java:86)
    at io.jhdf.dataset.chunked.indexing.FixedArrayIndex.<init>(FixedArrayIndex.java:83)
    at io.jhdf.dataset.chunked.ChunkedDatasetV4$ChunkLookupLazyInitializer.initialize(ChunkedDatasetV4.java:91)
    at io.jhdf.dataset.chunked.ChunkedDatasetV4$ChunkLookupLazyInitializer.initialize(ChunkedDatasetV4.java:69)
    at org.apache.commons.lang3.concurrent.LazyInitializer.get(LazyInitializer.java:143)
    at io.jhdf.dataset.chunked.ChunkedDatasetV4.getChunkLookup(ChunkedDatasetV4.java:63)
    at io.jhdf.dataset.chunked.ChunkedDatasetBase.isEmpty(ChunkedDatasetBase.java:306)
    at io.jhdf.dataset.DatasetBase.getData(DatasetBase.java:127)
    at org.java_jhdf.chunked_fixed_array_paged_no_filter_2d.run(chunked_fixed_array_paged_no_filter_2d.java:47)
    at org.java_jhdf.jmh_generated.chunked_fixed_array_paged_no_filter_2d_run_jmhTest.run_sample_jmhStub(chunked_fixed_array_paged_no_filter_2d_run_jmhTest.java:280)
    at org.java_jhdf.jmh_generated.chunked_fixed_array_paged_no_filter_2d_run_jmhTest.run_SampleTime(chunked_fixed_array_paged_no_filter_2d_run_jmhTest.java:234)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:527)
    at org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:504)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)

To Reproduce

chunked_new_chunk_indices_no_filter_2d.zip + the following code:

https://github.com/Apollo3zehn/hdf5-benchmark/blob/e6fd628b7a10303dc2b61e2b562673312ca3a5b0/java-jhdf/test/src/main/java/org/java_jhdf/chunked_fixed_array_paged_no_filter_2d.java#L21-L53

Expected behaviour

A clear and concise description of what you expected to happen.

Please complete the following information:

openjdk version "1.8.0_412"
OpenJDK Runtime Environment (build 1.8.0_412-8u412-ga-1~24.04.2-b08)
OpenJDK 64-Bit Server VM (build 25.412-b08, mixed mode)

Additional context Add any other context about the problem here, or possible solutions/workarounds.

I am not sure what exactly causes the issue. But I am deliberately creating a file with a fixed-array index with its elements stored in pages and then trying to read that for benchmarking purposes.

jamesmudd commented 1 week ago

Thanks I will take a look at this, should be easy to reproduce. I have the benchmark running locally.