#65 [PATCH] ncatted segfault with netcdf-4 files

closed-fixed
None
5
2013-04-19
2013-04-19
Etienne Tourigny
No

When deleting attributes in a netcdf-4 file, a segfault occurs. The same file in netcdf-3 format does not generate the segfault.

$ ncatted -h -a ,global,d,, tmp1.nc
Segmentation fault (core dumped)

The following one-liner resolves this. It seems that nco-4.2.6 (and probably earlier) is affected by this.

{{{
--- nco_att_utl.c.init 2013-04-19 17:06:28.002291682 -0300
+++ nco_att_utl.c 2013-04-19 17:06:33.158291816 -0300
@@ -233,6 +233,7 @@

if(
flg_fmt_netCDF4 && /* Output file is netCDF4 and ... */
+ aed.att_nm &&
!strcmp(aed.att_nm,nco_mss_val_sng_get()) && /* ... attribute is missing value and ... */
aed.mode != aed_delete){ /* ... we are not deleting attribute */
/* Rename existing attribute to netCDF4-safe name
}}}

Discussion

    • summary: ncatted segfault with netcdf-4 files --> [PATCH] ncatted segfault with netcdf-4 files
     
  • Charlie Zender
    Charlie Zender
    2013-04-19

    • assigned_to: nobody --> zender
    • status: open --> closed-fixed
     
  • Charlie Zender
    Charlie Zender
    2013-04-19

    Thank you, very much, for reporting this bug and fix. I verified the problem and applied the patch supplied. It's clear what caused the bug and the patch should work on all modern compilers. The fix has been committed and will be in NCO 4.3.1. cz