Hello everyone!
Short question: In a netcdf4-classic file, can a fixed-size dimension share the same name with a previously-defined variable?
A customer reported a MATLAB crash with following steps using our nccreate function. To me, this wouldn’t make sense to name the second variable’s dimension the same name as the first variable’s name. Wondering if this is related to issue #1528, but in our case they are fixed-size dimensions. We're using netcdf 4.7.3 and this is not OS-specific.
nccreate('test.nc','var1','Dimensions',{'dim1',3}); % one-dimension, vector of length 3
nccreate('test.nc','var2','Dimensions',{'var1',2}); % one-dimension, vector of length 2
This errors during nc_close() with error -101 NC_EHDFERR, and then we crash (oops). Note: nccreate defaults to netcdf4-classic. Calling it twice in succession like that means we first create new file test.nc and write var1 with dim1 to it, then close. Then reopen for append and create var2 with dimension name var1, then close.
I wrote a netcdf-c program (attached, netcdfRepro_VarDimError) to reproduce it (using netcdf-c v4.7.3), and still get the same NC_EHDFERR error, but no segfault or similar crash. (My repro is .c, but looks like github won't let me attach a .c file, so renamed it .txt).
netcdfRepro_VarDimError.txt
Hello everyone!
Short question: In a netcdf4-classic file, can a fixed-size dimension share the same name with a previously-defined variable?
A customer reported a MATLAB crash with following steps using our nccreate function. To me, this wouldn’t make sense to name the second variable’s dimension the same name as the first variable’s name. Wondering if this is related to issue #1528, but in our case they are fixed-size dimensions. We're using netcdf 4.7.3 and this is not OS-specific.
nccreate('test.nc','var1','Dimensions',{'dim1',3}); % one-dimension, vector of length 3
nccreate('test.nc','var2','Dimensions',{'var1',2}); % one-dimension, vector of length 2
This errors during nc_close() with error -101 NC_EHDFERR, and then we crash (oops). Note: nccreate defaults to netcdf4-classic. Calling it twice in succession like that means we first create new file test.nc and write var1 with dim1 to it, then close. Then reopen for append and create var2 with dimension name var1, then close.
I wrote a netcdf-c program (attached, netcdfRepro_VarDimError) to reproduce it (using netcdf-c v4.7.3), and still get the same NC_EHDFERR error, but no segfault or similar crash. (My repro is .c, but looks like github won't let me attach a .c file, so renamed it .txt).
netcdfRepro_VarDimError.txt