Java error "invalid memory access"

I got an error in processing Sentinel-2 C2RCC. It said about “java.lang.Error: Invalid memory access”. Have anyone knows what cases this error? Is that the problem of freezing in bulk processing?

Thank you in advance
Regards

17530 [main] INFO serverStartup - NetcdfLoader: set log level: old=0 new=0
17530 [main] INFO serverStartup - Nc4Iosp: set log level: old=0 new=0     
90% done.
java.lang.Error: Invalid memory access
        at com.sun.jna.Native.invokeInt(Native Method)   
        at com.sun.jna.Function.invoke(Function.java:426)
        at com.sun.jna.Function.invoke(Function.java:361)
        at com.sun.jna.Library$Handler.invoke(Library.java:265)
        at com.sun.proxy.$Proxy12.nc_def_grp(Unknown Source)
        at ucar.nc2.jni.netcdf.Nc4wrapper.nc_def_grp(Nc4wrapper.java:1608)
        at ucar.nc2.jni.netcdf.Nc4Iosp.createGroup(Nc4Iosp.java:2493)
        at ucar.nc2.jni.netcdf.Nc4Iosp.createGroup(Nc4Iosp.java:2498)
        at ucar.nc2.jni.netcdf.Nc4Iosp.createGroup(Nc4Iosp.java:2498)
        at ucar.nc2.jni.netcdf.Nc4Iosp.createGroup(Nc4Iosp.java:2498)
        at ucar.nc2.jni.netcdf.Nc4Iosp.createGroup(Nc4Iosp.java:2498)
        at ucar.nc2.jni.netcdf.Nc4Iosp.createGroup(Nc4Iosp.java:2498)
        at ucar.nc2.jni.netcdf.Nc4Iosp.createGroup(Nc4Iosp.java:2498)
        at ucar.nc2.jni.netcdf.Nc4Iosp.createGroup(Nc4Iosp.java:2498)
        at ucar.nc2.jni.netcdf.Nc4Iosp.createGroup(Nc4Iosp.java:2498)
        at ucar.nc2.jni.netcdf.Nc4Iosp.create(Nc4Iosp.java:2399)
        at ucar.nc2.NetcdfFileWriter.create(NetcdfFileWriter.java:902)
        at org.esa.snap.dataio.netcdf.nc.NFileWriteable.create(NFileWriteable.java:120)
        at org.esa.snap.dataio.netcdf.NetCdfWriteProfile.writeProduct(NetCdfWriteProfile.java:52)
        at org.esa.snap.dataio.netcdf.DefaultNetCdfWriter.writeProductNodesImpl(DefaultNetCdfWriter.java:65)
        at org.esa.snap.core.dataio.AbstractProductWriter.writeProductNodes(AbstractProductWriter.java:111)
        at org.esa.snap.core.gpf.common.WriteOp.doExecute(WriteOp.java:315)
        at org.esa.snap.core.gpf.internal.OperatorContext.executeOperator(OperatorContext.java:1300)
        at org.esa.snap.core.gpf.Operator.execute(Operator.java:153)
        at org.esa.snap.core.gpf.graph.GraphProcessor.executeGraph(GraphProcessor.java:198)
        at org.esa.snap.core.gpf.graph.GraphProcessor.executeGraph(GraphProcessor.java:128)
        at org.esa.snap.core.gpf.main.DefaultCommandLineContext.executeGraph(DefaultCommandLineContext.java:86)
        at org.esa.snap.core.gpf.main.CommandLineTool.executeGraph(CommandLineTool.java:547)
        at org.esa.snap.core.gpf.main.CommandLineTool.runGraph(CommandLineTool.java:391)
        at org.esa.snap.core.gpf.main.CommandLineTool.runGraphOrOperator(CommandLineTool.java:287)
        at org.esa.snap.core.gpf.main.CommandLineTool.run(CommandLineTool.java:188)
        at org.esa.snap.core.gpf.main.CommandLineTool.run(CommandLineTool.java:121)
        at org.esa.snap.core.gpf.main.GPT.run(GPT.java:59)
        at org.esa.snap.core.gpf.main.GPT.main(GPT.java:37)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.esa.snap.runtime.Launcher.lambda$run$0(Launcher.java:55)
        at org.esa.snap.runtime.Engine.runClientCode(Engine.java:189)
        at org.esa.snap.runtime.Launcher.run(Launcher.java:51)
        at org.esa.snap.runtime.Launcher.main(Launcher.java:31)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:84)
        at com.exe4j.runtime.WinLauncher.main(WinLauncher.java:94)
        at com.install4j.runtime.launcher.WinLauncher.main(WinLauncher.java:25)

Error: Invalid memory access

S2MSI_s2resample_subset_idepix_c2rcc.xml (3.0 KB)
snap.conf (639 Bytes)

Hi,

Yes, this can break your processing. But should actually only affect the product where this error happens. Can you reproduce this error? Does it happen only on one product or with multiple?

In general, it’s a strange error. Something seems to be wrong with the memory allocation done by NetCDF/jna. So, it is outside of the SNAP code base and writing to NetCDF works in general.

Unfortunately, the jna report does not give helpful indicators what the reason might be. Also, the internet gives no helping hand here. So, I can only do some guess work.

  • Maybe other application processes running in the background interfere with the data processing.
  • It could be that there is an issue with your memory
  • Maybe there is an issue in NetCDF implementation which occurs only in rare cases.

You can try it on other system or change the output format.
More help I can’t give at the moment, sorry

Thank you very much for your response. I appreciate all suggestions.

Just to let you know. This issue has been reported again.
NetCDF-CF writing: Segmentation fault and metadata issues with SNAP v9.0.4+ - snap / Problem Reports - STEP Forum (esa.int)

We have now created a ticket for it and will further investigate it.
[SNAP-3509] Invalid memory access error occurs when writing NetCDF-CF file

I’ve investigated this issue and it some that two things come together here.
NetCDF-CF has a limit of 32768 groups and S2 is structured in a way that for some products this number is exceeded. We will further work on finding a solution. It might be, that we need to restructure the metadata of Sentinel-2. Especially the data which is currently shown under Satellite_Ancillary_Data_Info:


But this is further under investigation.

For the time being, if the metadata is not important for you, you can remove them by adding a subset operator to the graph.

   <node id="removeMetadata">
      <operator>Subset</operator>
      <sources>
        <source>input</source>
      </sources>
      <parameters>
        <copyMetadata>false</copyMetadata>
      </parameters>
    </node>

In SNAP Desktop the metadata node Satellite_Ancillary_Data_Info can simply be removed by pressing the DEL-key.
image