NetCDF-CF writing: Segmentation fault and metadata issues with SNAP v9.0.4+

Module: org.esa.snap.snap.netcdf

Version: 9.0.4+ (9.0.2+)

When using the SNAP v9.0.4+ to write NetCDF-CF files, there seems to be a bug that leads to a segmentation fault in the netCDF library for certain input products. Additionally, those that do succeed output NetCDFs that have issues with standard tools like gdalinfo, so there is probably something wrong with the way how metadata is written into them. (The last working version is v9.0.1, apart from the fact that it’s not writing any metadata.)


  • Downgrade to v9.0.1 (not an option for me since then other bugs start to affect S2Resampling).
  • Change output format to NetCDF-BEAM.

Steps to reproduce:

  1. Use SNAP and S3TBX updated to the latest versions (9.0.6 and 9.0.3 at the moment of writing).
  2. Start with S2B_MSIL1C_20230502T095029_N0509_R079_T34VEH_20230502T104128.SAFE (Sentinel-2 product).
  3. Process the product using a graph containing S2Resampling, C2RCC, and Write (as NetCDF-CF) pipelined after each other. See attachment (run.xml).
  4. The writing will fail due to an error coming from the netCDF writing part. The Windows and Linux error messages are slightly different (see attachments), but both hint at a segmentation fault or a memory access error.

Attached to this bug report is also a Linux error report file (hs_err_pid7254.log) with more information about the segmentation fault and the NetCDF library error. It seems to emerge from the metadata group creation part.


linux_error_log.txt (2.3 KB)
hs_err_pid7254.log (261.6 KB)
run.xml (2.4 KB)
windows_error_log.txt (5.2 KB)

Here’s an example of a tile which goes successfully through the workflow and looks all right when viewed in SNAP: S2A_MSIL1C_20230503T101021_N0509_R022_T34WFS_20230503T135150.SAFE

However, GDAL has an issue with the output netCDF. For example the following two commands never return.

gdal_translate lat.vrt

Thanks for the report. I was able to reproduce this.
We will investigate this further: [SNAP-3509] Invalid memory access error occurs when writing NetCDF-CF file

It has been reported before Java error “invalid memory access” - snap - STEP Forum (

The reason for this issue has been found:
I wrote about it here: