From 47dcd00bb75ba2aa55b82c615cac935a5ffd4efd Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Tue, 16 Feb 2016 10:23:53 -0700 Subject: [PATCH 01/15] Added test file for debugging https://github.com/Unidata/netcdf-c/issues/221. --- .gitignore | 1 - gh221.nc.gz | Bin 0 -> 15059 bytes 2 files changed, 1 deletion(-) create mode 100644 gh221.nc.gz diff --git a/.gitignore b/.gitignore index f042b35a1..2273a6bc5 100644 --- a/.gitignore +++ b/.gitignore @@ -34,7 +34,6 @@ scan-build .deps .libs *.zip -*.gz Makefile .DS_Store build-par diff --git a/gh221.nc.gz b/gh221.nc.gz new file mode 100644 index 0000000000000000000000000000000000000000..1cb77cdb4ce07ed7b762810bfd364710a9397b54 GIT binary patch literal 15059 zcmeI&{ZkSK7zc1XU*@(e^f2&}VY^68y_^oy+=AK6jWhJFQloNAa`~Fe&6ja>+GUL; z*=WA)eCzex#G#1_QwNlmlm`-~CXwLlq<|gZ3o-?^{)F9m`=NWDdwzWG`9Amg`SE9a zdOkvnQxLA1SrHN8d-6{q3@Sw~HW`aB3A-r1qums84%ZFqt~~y0Yz0OckiVBgpnQq? z#zYtFee%hno77K{7u;jb0iHO~ca~sHoC#^t-M^g~_KwDlx1>K)OF2AC<|tUQkw0i% zTI*C)SHo0N9U85u+#gwcC;JE7IFUKS;(vVNnMANM8kL*yZd1mFdS1nEVVur-bhi^v zs9047vZe6`Ts*Rvsa_Xp=>^=J{IP|ha*TdZnUI`tScreCzvG$ocG6LbyswpUciqy^ zd6tO1R(fusBVxm#AF(!+pO|QTd*{K6C|hxOzc=@!?2p6L)FqY1u5Za7i}r8qalUTM|D1%GulJ9GYsf zhdTAAnQGC*0KGVKQDhX^o0v?M(aKb5M4I%cu~tW-b@i{+p3q>-gD{1}Os=W=fK!zb z9r)oxnSY%+CQ4q&e-ZfDu;2(u*;?^3yRoskCU`%_;y6JLRzpdnl@s8H50kEATK2f_$>RmJI+|*aNTn6k;Ped ziDaG0>sd~Tp?X}yhjV8e4^Ged`*dzo%F)WA=WJslvuC{h7IRnYt^TLRBCC+eN?%RQ z`aE#-iR6I?Chdjvqqs3i$XIEgQ`+`RGtz4+kH@Qyx_p_7{o2<&vP~mZvu{V Date: Tue, 16 Feb 2016 11:00:09 -0700 Subject: [PATCH 02/15] Roughing in a test to create the failure described in https://github.com/Unidata/netcdf-c/issues/221 --- nc_test4/CMakeLists.txt | 2 +- nc_test4/tst_gh221.c | 60 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 nc_test4/tst_gh221.c diff --git a/nc_test4/CMakeLists.txt b/nc_test4/CMakeLists.txt index 28a066ba6..1bc01286f 100644 --- a/nc_test4/CMakeLists.txt +++ b/nc_test4/CMakeLists.txt @@ -9,7 +9,7 @@ SET(NC4_TESTS tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars t_type cdm_sea_soundings tst_vl tst_atts1 tst_atts2 tst_vars2 tst_files5 tst_files6 tst_sync tst_h_strbug tst_h_refs tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite - tst_put_vars_two_unlim_dim) + tst_put_vars_two_unlim_dim tst_gh221) # Note, renamegroup needs to be compiled before run_grp_rename build_bin_test(renamegroup) diff --git a/nc_test4/tst_gh221.c b/nc_test4/tst_gh221.c new file mode 100644 index 000000000..90594ea33 --- /dev/null +++ b/nc_test4/tst_gh221.c @@ -0,0 +1,60 @@ +/* This is part of the netCDF package. Copyright 2005 University + Corporation for Atmospheric Research/Unidata See COPYRIGHT file for + conditions of use. + + This program excersizes HDF5 variable length array code. + + $Id: tst_h_vl2.c,v 1.5 2010/06/01 15:34:52 ed Exp $ +*/ +#include +#include +#include + +#define FILE_NAME "tst_gh221.nc" +#define DIM_LEN 3; +#define DIM_NAME "x" +#define VLNE_NAME "vltest" +#define VAR_NAME1 "v" +#define VAR_NAME2 "w" + +int main() { + + printf("Testing access to unset entrines in VLEN variable\n"); + { + int ncid, typeid, dimid; + nc_vlen_t data[DIM_LEN], data_in[DIM_LEN]; + + size_t size_in; + nc_type base_nc_type_in; + int *phony, class_in; + size_t len_in; + int i, j; + + /* Create phony data. */ + for (i=0; i Date: Tue, 16 Feb 2016 14:40:09 -0700 Subject: [PATCH 03/15] Additional work debugging issue. --- gh221.nc.gz | Bin 15059 -> 0 bytes nc_test4/tst_gh221.c | 114 +++++++++++++++++++++++++++++++++---------- 2 files changed, 89 insertions(+), 25 deletions(-) delete mode 100644 gh221.nc.gz diff --git a/gh221.nc.gz b/gh221.nc.gz deleted file mode 100644 index 1cb77cdb4ce07ed7b762810bfd364710a9397b54..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15059 zcmeI&{ZkSK7zc1XU*@(e^f2&}VY^68y_^oy+=AK6jWhJFQloNAa`~Fe&6ja>+GUL; z*=WA)eCzex#G#1_QwNlmlm`-~CXwLlq<|gZ3o-?^{)F9m`=NWDdwzWG`9Amg`SE9a zdOkvnQxLA1SrHN8d-6{q3@Sw~HW`aB3A-r1qums84%ZFqt~~y0Yz0OckiVBgpnQq? z#zYtFee%hno77K{7u;jb0iHO~ca~sHoC#^t-M^g~_KwDlx1>K)OF2AC<|tUQkw0i% zTI*C)SHo0N9U85u+#gwcC;JE7IFUKS;(vVNnMANM8kL*yZd1mFdS1nEVVur-bhi^v zs9047vZe6`Ts*Rvsa_Xp=>^=J{IP|ha*TdZnUI`tScreCzvG$ocG6LbyswpUciqy^ zd6tO1R(fusBVxm#AF(!+pO|QTd*{K6C|hxOzc=@!?2p6L)FqY1u5Za7i}r8qalUTM|D1%GulJ9GYsf zhdTAAnQGC*0KGVKQDhX^o0v?M(aKb5M4I%cu~tW-b@i{+p3q>-gD{1}Os=W=fK!zb z9r)oxnSY%+CQ4q&e-ZfDu;2(u*;?^3yRoskCU`%_;y6JLRzpdnl@s8H50kEATK2f_$>RmJI+|*aNTn6k;Ped ziDaG0>sd~Tp?X}yhjV8e4^Ged`*dzo%F)WA=WJslvuC{h7IRnYt^TLRBCC+eN?%RQ z`aE#-iR6I?Chdjvqqs3i$XIEgQ`+`RGtz4+kH@Qyx_p_7{o2<&vP~mZvu{V #include #include #define FILE_NAME "tst_gh221.nc" -#define DIM_LEN 3; +//#define DIM_LEN NC_UNLIMITED +#define DIM_LEN 5 #define DIM_NAME "x" -#define VLNE_NAME "vltest" +#define VLEN_NAME "vltest" #define VAR_NAME1 "v" #define VAR_NAME2 "w" +#define ROW_COUNT 3 +#define VLEN0 2 +#define VLEN1 3 +#define VLEN2 3 int main() { - printf("Testing access to unset entrines in VLEN variable\n"); + printf("Testing access to unset entries in VLEN variable\n"); { - int ncid, typeid, dimid; - nc_vlen_t data[DIM_LEN], data_in[DIM_LEN]; - - size_t size_in; - nc_type base_nc_type_in; - int *phony, class_in; - size_t len_in; - int i, j; - - /* Create phony data. */ - for (i=0; i Date: Tue, 16 Feb 2016 14:52:03 -0700 Subject: [PATCH 04/15] Have duplicated issue reported in #221 at github. --- nc_test4/tst_gh221.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nc_test4/tst_gh221.c b/nc_test4/tst_gh221.c index dad16a8d7..5e911f545 100644 --- a/nc_test4/tst_gh221.c +++ b/nc_test4/tst_gh221.c @@ -19,8 +19,8 @@ #include #define FILE_NAME "tst_gh221.nc" -//#define DIM_LEN NC_UNLIMITED -#define DIM_LEN 5 +#define DIM_LEN NC_UNLIMITED +//#define DIM_LEN 5 #define DIM_NAME "x" #define VLEN_NAME "vltest" #define VAR_NAME1 "v" @@ -105,10 +105,11 @@ int main() { data[2].p = dat2; data[2].len = VLEN2; - printf("\t* Puting data in VLEN variable:\tnc_put_vara().\n"); + + //printf("\t* Puting data in VLEN variable:\tnc_put_vara().\n"); //stat = nc_put_vara(ncid,varid,&startp,&countp,data); - stat = nc_put_var(ncid,varid,data); - if(stat) ERR; + //stat = nc_put_var(ncid,varid,&data); + //if(stat) ERR; From 0eff434098777936269ecfe86399902b89d5cbdc Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Tue, 16 Feb 2016 14:54:10 -0700 Subject: [PATCH 05/15] Renamed test file to be more reflective for what it is doing. --- nc_test4/CMakeLists.txt | 7 +------ nc_test4/Makefile.am | 7 ++++--- nc_test4/{tst_gh221.c => tst_empty_vlen_unlim.c} | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) rename nc_test4/{tst_gh221.c => tst_empty_vlen_unlim.c} (98%) diff --git a/nc_test4/CMakeLists.txt b/nc_test4/CMakeLists.txt index 1bc01286f..d30257ff2 100644 --- a/nc_test4/CMakeLists.txt +++ b/nc_test4/CMakeLists.txt @@ -9,7 +9,7 @@ SET(NC4_TESTS tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars t_type cdm_sea_soundings tst_vl tst_atts1 tst_atts2 tst_vars2 tst_files5 tst_files6 tst_sync tst_h_strbug tst_h_refs tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite - tst_put_vars_two_unlim_dim tst_gh221) + tst_put_vars_two_unlim_dim tst_empty_vlen_unlim) # Note, renamegroup needs to be compiled before run_grp_rename build_bin_test(renamegroup) @@ -82,8 +82,3 @@ IF(TEST_PARALLEL) build_bin_test(tst_mode) add_sh_test(nc_test4 run_par_test) ENDIF() - -## Specify files to be distributed by 'make dist' -FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.c ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.sh) -SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am) -SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} ref_chunks1.cdl ref_chunks2.cdl ref_tst_compounds.nc ref_tst_xplatform2_1.nc ref_tst_xplatform2_2.nc ref_tst_dims.nc ref_tst_interops4.nc ref_grp_rename.cdl ref_tst_nvars.nc contig.hdf4 chunked.hdf4) diff --git a/nc_test4/Makefile.am b/nc_test4/Makefile.am index 5d03046a7..810878db4 100644 --- a/nc_test4/Makefile.am +++ b/nc_test4/Makefile.am @@ -21,7 +21,8 @@ tst_chunks tst_chunks2 tst_utf8 tst_fills tst_fills2 tst_fillbug \ tst_xplatform tst_xplatform2 tst_h_atts2 tst_endian_fill tst_atts \ t_type cdm_sea_soundings tst_camrun tst_vl tst_atts1 tst_atts2 \ tst_vars2 tst_files5 tst_files6 tst_sync tst_h_strbug tst_h_refs \ -tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite +tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite \ +tst_empty_vlen_unlim check_PROGRAMS = $(NC4_TESTS) renamegroup @@ -123,7 +124,7 @@ ref_tst_interops4.nc run_get_knmi_files.sh CMakeLists.txt \ run_grp_rename.sh tst_formatx_hdf4.sh \ run_chunk_hdf4.sh contiguous.hdf4 chunked.hdf4 \ tst_h5_endians.c tst_h4_lendian.c tst_atts_string_rewrite.c \ -tst_put_vars_two_unlim_dim.c +tst_put_vars_two_unlim_dim.c tst_empty_vlen_unlim.c CLEANFILES = tst_mpi_parallel.bin cdm_sea_soundings.nc bm_chunking.nc \ bm_radar.nc bm_radar1.nc radar_3d_compression_test.txt \ @@ -134,7 +135,7 @@ tst_elena_*.cdl tst_simple*.cdl tst_chunks.cdl pr_A1.* tauu_A1.* \ usi_01.* thetau_01.* tst_*.nc tst_*.h5 \ tst_grp_rename.cdl tst_grp_rename.nc tst_grp_rename.dmp ref_grp_rename.cdl \ foo1.nc tst_interops2.h4 tst_h5_endians.nc tst_h4_lendian.h4 test.nc \ -tst_atts_string_rewrite.nc +tst_atts_string_rewrite.nc tst_empty_vlen_unlim.nc if USE_HDF4_FILE_TESTS DISTCLEANFILES = AMSR_E_L2_Rain_V10_200905312326_A.hdf \ diff --git a/nc_test4/tst_gh221.c b/nc_test4/tst_empty_vlen_unlim.c similarity index 98% rename from nc_test4/tst_gh221.c rename to nc_test4/tst_empty_vlen_unlim.c index 5e911f545..9f3323f41 100644 --- a/nc_test4/tst_gh221.c +++ b/nc_test4/tst_empty_vlen_unlim.c @@ -18,7 +18,7 @@ #include #include -#define FILE_NAME "tst_gh221.nc" +#define FILE_NAME "tst_empty_vlen_unlim.nc" #define DIM_LEN NC_UNLIMITED //#define DIM_LEN 5 #define DIM_NAME "x" From 791800145a50c8ac9989bfb003c8bda058073838 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Thu, 18 Feb 2016 17:33:49 +0000 Subject: [PATCH 06/15] Added test file for debugging issue. --- gh221.nc.gz | Bin 0 -> 15058 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 gh221.nc.gz diff --git a/gh221.nc.gz b/gh221.nc.gz new file mode 100644 index 0000000000000000000000000000000000000000..e7adbb404ff9907deb28f29877ada96cf9d37862 GIT binary patch literal 15058 zcmeI&|5MTj7zc1Xzszk{=xO35!*-FHdN~`0xdo${8)xX9rAFnPWcf9h3w7S7(=KZ) z$<5}souYj`H*jd8$kZXFCCdW|Q>Z5@f6;KZmXtyHjN!@s9? zXswgPj)uwjIv*cJ#es<0yIJ4i#z@FCOYrfDXOgbv5n@j4yN&7V>N%C5x%f=xANShv zgz^<-AX^$^#KoWs5%ro_%gEf(ZXsZ`(8Jo%o|Pc@MYv-r7P# z`#BQ!ddUS{+un7fVc6PGc4D0K_Rd3>y=;Zyy`H?2vMYv+f#uI^yNTq#yX$S;oywq7 zwCxqXxupwoE<=F1Q5VqV&`@o5TWeSwzpq16pPI$8h!$mY&M`cvmPOI?(~j;Q$KYh+ zMySJZ22qR0`x%89^J0^DqY*(=CM%-Sh&5?XDOP)&b>*)WVQ4VsVVFWg*v&TgzW&aX3vi!3Qu4_9JDFkI}!->d7`{@nEpbe$a11 z(d=B1{C(>U>FTn=pG>Z2|K`IQm*($}OdZ~MH65|4lb4XX1gwnR zkz@_w3zw3j=x*2X;k+5np{ZGa@AhpJ>!9^X3c&@->~`%t}WIA^eBAG>+ivvcD`wP>Ot38^?zv7 Pn$t_K<>Jbq`>1~aYl0Bc literal 0 HcmV?d00001 From e2eda755e3e1b5db7bbb463c09773ff2c1852d06 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Thu, 18 Feb 2016 13:59:53 -0700 Subject: [PATCH 07/15] Tweaked empty test to check for limited, unlimited dimensions. Also added a gdb command file for ease of debugging. --- gdb.txt | 15 +++++ nc_test4/tst_empty_vlen_unlim.c | 111 ++++++++++++++++++++++++++++++-- 2 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 gdb.txt diff --git a/gdb.txt b/gdb.txt new file mode 100644 index 000000000..8b67f6f37 --- /dev/null +++ b/gdb.txt @@ -0,0 +1,15 @@ +set breakpoint pending on + +break nc4hdf.c:872 +command +watch provide_fill +c +end + + +break nc4hdf.c:974 +command +print fill_value_size +end + +break nc4hdf.c:1126 diff --git a/nc_test4/tst_empty_vlen_unlim.c b/nc_test4/tst_empty_vlen_unlim.c index 9f3323f41..63f15356a 100644 --- a/nc_test4/tst_empty_vlen_unlim.c +++ b/nc_test4/tst_empty_vlen_unlim.c @@ -18,9 +18,10 @@ #include #include -#define FILE_NAME "tst_empty_vlen_unlim.nc" -#define DIM_LEN NC_UNLIMITED -//#define DIM_LEN 5 +#define FILE_NAME_UNLIM "tst_empty_vlen_unlim.nc" +#define FILE_NAME_LIM "tst_empty_vlen_lim.nc" +#define DIM_LEN_UNLIM NC_UNLIMITED +#define DIM_LEN_LIM 5 #define DIM_NAME "x" #define VLEN_NAME "vltest" #define VAR_NAME1 "v" @@ -32,7 +33,7 @@ int main() { - printf("Testing access to unset entries in VLEN variable\n"); + printf("Testing access to unset entries in VLEN variable, unlimited dimension\n"); { int ncid, typeid, dimid, varid, varid2; nc_vlen_t data[ROW_COUNT]; @@ -46,11 +47,15 @@ int main() { int i = 0; /* Create File */ printf("\t* Creating File:\tnc_create()\n"); - if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR; + if (nc_create(FILE_NAME_UNLIM, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR; + + /* Set fill mode */ + //printf("\t* Setting fill mode:\tnc_set_fill()\n"); + //if(nc_set_fill(ncid,NC_FILL,NULL)) ERR; /* Create Dimension */ printf("\t* Defining Unlimited Dimension:\tnc_def_dim()\n"); - if (nc_def_dim(ncid, DIM_NAME, DIM_LEN, &dimid)) ERR; + if (nc_def_dim(ncid, DIM_NAME, DIM_LEN_UNLIM, &dimid)) ERR; /* Create ragged array type. */ printf("\t* Creating Ragged Array type:\tnc_def_vlen().\n"); @@ -119,6 +124,100 @@ int main() { } + + printf("Testing access to unset entries in VLEN variable, unlimit dimension\n"); + { + int ncid, typeid, dimid, varid, varid2; + nc_vlen_t data[ROW_COUNT]; + int stat; + float *dat0, *dat1, *dat2; + float *data2; + size_t startp[3] = {0,0,0}; + size_t countp[3] = {VLEN0,VLEN1,VLEN2}; + size_t startp2[1] = {0}; + size_t countp2[1] = {VLEN2}; + int i = 0; + /* Create File */ + printf("\t* Creating File:\tnc_create()\n"); + if (nc_create(FILE_NAME_LIM, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR; + + /* Set fill mode */ + //printf("\t* Setting fill mode:\tnc_set_fill()\n"); + //if(nc_set_fill(ncid,NC_FILL,NULL)) ERR; + + /* Create Dimension */ + printf("\t* Defining Unlimited Dimension:\tnc_def_dim()\n"); + if (nc_def_dim(ncid, DIM_NAME, DIM_LEN_LIM, &dimid)) ERR; + + /* Create ragged array type. */ + printf("\t* Creating Ragged Array type:\tnc_def_vlen().\n"); + if (nc_def_vlen(ncid, VLEN_NAME, NC_FLOAT, &typeid)) ERR; + + /* Create a variable of typeid. */ + printf("\t* Creating Variable using Ragged Arrayt Type:\tnc_def_var().\n"); + if (nc_def_var(ncid, VAR_NAME1, typeid, 1, &dimid, &varid)) ERR; + + /* Create a variable of type float. */ + printf("\t* Creating secondary Variable using NC_FLOAT:\tnc_def_var().\n"); + if (nc_def_var(ncid, VAR_NAME2, NC_FLOAT, 1, &dimid, &varid2)) ERR; + + /* End define mode. */ + printf("\t* Ending define mode:\tnc_enddef().\n"); + + /* Write out data for w */ + printf("\t* Creating float data for secondary variable.\n"); + data2 = (float*)malloc(sizeof(float) * VLEN2); + for(i = 0; i < VLEN2; i++) { + data2[i] = (float)i; + } + + printf("\t* Puting data in secondary variable:\tnc_put_vara().\n"); + if (nc_put_vara(ncid,varid2,&startp2,&countp2,data2)) ERR; + + /***********/ + /* Actually unnecessary to recreate the issue. */ + /***********/ + + + /* Write out varying-length data for v[0] and v[1]. Leave v[2] empty. */ + + dat0 = (float*)malloc(VLEN0 * sizeof(float)); + for(i = 0; i < VLEN0; i++) { + dat0[i] = (float)i; + } + dat1 = (float*)malloc(VLEN1 * sizeof(float)); + for(i = 0; i < VLEN1; i++) { + dat1[i] = (float)i; + } + dat2 = (float*)malloc(VLEN2 * sizeof(float)); + for(i = 0; i < VLEN2; i++) { + dat2[i] = (float)i; + } + + data[0].p = dat0; + data[0].len = VLEN0; + + data[1].p = dat1; + data[1].len = VLEN1; + + data[2].p = dat2; + data[2].len = VLEN2; + + //printf("\t* Puting data in VLEN variable:\tnc_put_vara().\n"); + //stat = nc_put_vara(ncid,varid,&startp,&countp,data); + //stat = nc_put_var(ncid,varid,&data); + //if(stat) ERR; + + + + /* Close File. */ + printf("\t* Closing file:\tnc_close().\n"); + if (stat = nc_close(ncid)) ERR; + + + } + + SUMMARIZE_ERR; FINAL_RESULTS; From 08e8374b029b188d17d144a1b7e165f042b36a37 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Thu, 18 Feb 2016 14:45:57 -0700 Subject: [PATCH 08/15] Tentative fix for initial issue at http://github.com/Unidata/netcdf-c/issues/221, investigating knock-on issues now. --- gdb.txt | 29 +++++++++++++++++------------ libsrc4/nc4hdf.c | 5 ++++- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/gdb.txt b/gdb.txt index 8b67f6f37..31d374d10 100644 --- a/gdb.txt +++ b/gdb.txt @@ -1,15 +1,20 @@ -set breakpoint pending on - -break nc4hdf.c:872 -command -watch provide_fill -c -end -break nc4hdf.c:974 -command -print fill_value_size -end +#---------- +# Solved first set of problems. On to second, in print_any_val. +#--------- +#set breakpoint pending on -break nc4hdf.c:1126 +#break nc4hdf.c:872 +#command +#watch provide_fill +#c +#end + + +#break nc4hdf.c:974 +#command +#print fill_value_size +#end + +#break nc4hdf.c:1126 diff --git a/libsrc4/nc4hdf.c b/libsrc4/nc4hdf.c index f90401aed..0b6aba7c1 100644 --- a/libsrc4/nc4hdf.c +++ b/libsrc4/nc4hdf.c @@ -1147,6 +1147,7 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp, filldata = (char *)data + real_data_size; for (i = 0; i < fill_len; i++) { + if (var->type_info->nc_type_class == NC_STRING) { if (*(char **)fillvalue) @@ -1157,7 +1158,9 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp, else *(char **)filldata = NULL; } - else + else if(var->type_info->nc_type_class == NC_VLEN) { + continue; + } else memcpy(filldata, fillvalue, file_type_size); filldata = (char *)filldata + file_type_size; } From 9791b1a3978afb6b97e483c8b2ead586f51069f6 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Thu, 18 Feb 2016 14:45:57 -0700 Subject: [PATCH 09/15] Tentative fix for initial issue at http://github.com/Unidata/netcdf-c/issues/221 . investigating knock-on issues now. --- gdb.txt | 29 +++++++++++++++++------------ libsrc4/nc4hdf.c | 5 ++++- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/gdb.txt b/gdb.txt index 8b67f6f37..31d374d10 100644 --- a/gdb.txt +++ b/gdb.txt @@ -1,15 +1,20 @@ -set breakpoint pending on - -break nc4hdf.c:872 -command -watch provide_fill -c -end -break nc4hdf.c:974 -command -print fill_value_size -end +#---------- +# Solved first set of problems. On to second, in print_any_val. +#--------- +#set breakpoint pending on -break nc4hdf.c:1126 +#break nc4hdf.c:872 +#command +#watch provide_fill +#c +#end + + +#break nc4hdf.c:974 +#command +#print fill_value_size +#end + +#break nc4hdf.c:1126 diff --git a/libsrc4/nc4hdf.c b/libsrc4/nc4hdf.c index f90401aed..0b6aba7c1 100644 --- a/libsrc4/nc4hdf.c +++ b/libsrc4/nc4hdf.c @@ -1147,6 +1147,7 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp, filldata = (char *)data + real_data_size; for (i = 0; i < fill_len; i++) { + if (var->type_info->nc_type_class == NC_STRING) { if (*(char **)fillvalue) @@ -1157,7 +1158,9 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp, else *(char **)filldata = NULL; } - else + else if(var->type_info->nc_type_class == NC_VLEN) { + continue; + } else memcpy(filldata, fillvalue, file_type_size); filldata = (char *)filldata + file_type_size; } From db84f39adcc15f8b7a205bf5762eca1334ecc261 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Thu, 18 Feb 2016 15:42:03 -0700 Subject: [PATCH 10/15] Tentative, robust fix for https://github.com/Unidata/netcdf-c/issues/221 that does not immediately introduce other issues into ncdump. Broader validation pending. --- gdb.txt | 33 +++++++++++++++++++++++++-------- libsrc4/nc4hdf.c | 6 +++++- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/gdb.txt b/gdb.txt index 31d374d10..f1c255143 100644 --- a/gdb.txt +++ b/gdb.txt @@ -1,20 +1,37 @@ +set breakpoint pending on +break nc4hdf.c:872 +command +watch provide_fill +c +end + +break vardata.c:473 +command +watch vals +end + + +break dumplib.c:1063 +command +print len +end + +break ncdump.c:1687 + +break nc4hdf.c:1126 + +run tst_empty_vlen_unlim.nc #---------- # Solved first set of problems. On to second, in print_any_val. #--------- -#set breakpoint pending on +# + -#break nc4hdf.c:872 -#command -#watch provide_fill -#c -#end #break nc4hdf.c:974 #command #print fill_value_size #end - -#break nc4hdf.c:1126 diff --git a/libsrc4/nc4hdf.c b/libsrc4/nc4hdf.c index 0b6aba7c1..2edfb4de6 100644 --- a/libsrc4/nc4hdf.c +++ b/libsrc4/nc4hdf.c @@ -1159,7 +1159,11 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp, *(char **)filldata = NULL; } else if(var->type_info->nc_type_class == NC_VLEN) { - continue; + if(fillvalue) { + memcpy(filldata,fillvalue,file_type_size); + } else { + *(char **)filldata = NULL; + } } else memcpy(filldata, fillvalue, file_type_size); filldata = (char *)filldata + file_type_size; From 1affd12fc82c6253e9078a14b5b408beda5c1fd6 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Fri, 19 Feb 2016 10:16:42 -0700 Subject: [PATCH 11/15] Wired tests for https://github.com/Unidata/netcdf-c/issues/221 into a shell script so that the generated files can be checked easily with ncdump. Added the test and associated files to both cmake and autotools build systems. --- nc_test4/CMakeLists.txt | 11 +++++++++-- nc_test4/Makefile.am | 8 ++++---- nc_test4/run_empty_vlen_test.sh | 34 +++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 6 deletions(-) create mode 100755 nc_test4/run_empty_vlen_test.sh diff --git a/nc_test4/CMakeLists.txt b/nc_test4/CMakeLists.txt index d30257ff2..566891210 100644 --- a/nc_test4/CMakeLists.txt +++ b/nc_test4/CMakeLists.txt @@ -9,19 +9,26 @@ SET(NC4_TESTS tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars t_type cdm_sea_soundings tst_vl tst_atts1 tst_atts2 tst_vars2 tst_files5 tst_files6 tst_sync tst_h_strbug tst_h_refs tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite - tst_put_vars_two_unlim_dim tst_empty_vlen_unlim) + tst_put_vars_two_unlim_dim) # Note, renamegroup needs to be compiled before run_grp_rename build_bin_test(renamegroup) add_sh_test(nc_test4 run_grp_rename) +## +# The shell script, run_empty_vlen_test.sh, +# depends on the 'tst_empty_vlen_unlim' binary. +## +BUILD_BIN_TEST(tst_empty_vlen_unlim) +ADD_SH_TEST(nc_test4 run_empty_vlen_test) + + IF(NOT MSVC) SET(NC4_TESTS ${NC4_TESTS} tst_interops5 tst_camrun) ENDIF() # If the v2 API was built, add the test program. IF(ENABLE_V2_API) - build_bin_test(tst_v2) ENDIF() diff --git a/nc_test4/Makefile.am b/nc_test4/Makefile.am index 810878db4..c3e6173bb 100644 --- a/nc_test4/Makefile.am +++ b/nc_test4/Makefile.am @@ -24,7 +24,7 @@ tst_vars2 tst_files5 tst_files6 tst_sync tst_h_strbug tst_h_refs \ tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite \ tst_empty_vlen_unlim -check_PROGRAMS = $(NC4_TESTS) renamegroup +check_PROGRAMS = $(NC4_TESTS) renamegroup tst_empty_vlen_unlim # Add these if large file tests are turned on. if LARGE_FILE_TESTS @@ -33,7 +33,7 @@ endif TESTS = $(NC4_TESTS) -TESTS += run_grp_rename.sh +TESTS += run_grp_rename.sh run_empty_vlen_test # If the v2 API was built, add its test program. if BUILD_V2 @@ -124,7 +124,7 @@ ref_tst_interops4.nc run_get_knmi_files.sh CMakeLists.txt \ run_grp_rename.sh tst_formatx_hdf4.sh \ run_chunk_hdf4.sh contiguous.hdf4 chunked.hdf4 \ tst_h5_endians.c tst_h4_lendian.c tst_atts_string_rewrite.c \ -tst_put_vars_two_unlim_dim.c tst_empty_vlen_unlim.c +tst_put_vars_two_unlim_dim.c tst_empty_vlen_unlim.c run_empty_vlen_test.sh CLEANFILES = tst_mpi_parallel.bin cdm_sea_soundings.nc bm_chunking.nc \ bm_radar.nc bm_radar1.nc radar_3d_compression_test.txt \ @@ -135,7 +135,7 @@ tst_elena_*.cdl tst_simple*.cdl tst_chunks.cdl pr_A1.* tauu_A1.* \ usi_01.* thetau_01.* tst_*.nc tst_*.h5 \ tst_grp_rename.cdl tst_grp_rename.nc tst_grp_rename.dmp ref_grp_rename.cdl \ foo1.nc tst_interops2.h4 tst_h5_endians.nc tst_h4_lendian.h4 test.nc \ -tst_atts_string_rewrite.nc tst_empty_vlen_unlim.nc +tst_atts_string_rewrite.nc tst_empty_vlen_unlim.nc tst_empty_vlen_lim.nc if USE_HDF4_FILE_TESTS DISTCLEANFILES = AMSR_E_L2_Rain_V10_200905312326_A.hdf \ diff --git a/nc_test4/run_empty_vlen_test.sh b/nc_test4/run_empty_vlen_test.sh new file mode 100755 index 000000000..adddd29a2 --- /dev/null +++ b/nc_test4/run_empty_vlen_test.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# +# Front-end for tst_empty_vlen_unlim.c. This test +# ensures that valid netcdf files are generated when +# a ragged VLEN array is defined but not populated. +# +# This script runs tst_empty_vlen_unlim and then +# runs `ncdump` against the two generated files. +# +# See https://github.com/Unidata/netcdf-c/issues/221 for +# full details. +# + +set -e + +if test "x$srcdir" = x ; then +srcdir=`pwd` +fi + +echo "" +echo "* Testing Empty Ragged Arrays (VLEN)" + +echo "Generating test netcdf files." +./tst_empty_vlen_unlim + +echo "Validating Files with ncdump." +echo "======================================" +../ncdump/ncdump -s tst_empty_vlen_unlim.nc +echo "---------------------------------------" +../ncdump/ncdump -s tst_empty_vlen_lim.nc +echo "======================================" + +echo "* Tests Passed." +exit 0 From dde10a7461f15608fd3ba51cf3a201c9a1584c00 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Fri, 19 Feb 2016 10:52:16 -0700 Subject: [PATCH 12/15] Corrected a missing suffix in Makefile.am --- nc_test4/Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nc_test4/Makefile.am b/nc_test4/Makefile.am index c3e6173bb..36c6bdcbf 100644 --- a/nc_test4/Makefile.am +++ b/nc_test4/Makefile.am @@ -22,7 +22,6 @@ tst_xplatform tst_xplatform2 tst_h_atts2 tst_endian_fill tst_atts \ t_type cdm_sea_soundings tst_camrun tst_vl tst_atts1 tst_atts2 \ tst_vars2 tst_files5 tst_files6 tst_sync tst_h_strbug tst_h_refs \ tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite \ -tst_empty_vlen_unlim check_PROGRAMS = $(NC4_TESTS) renamegroup tst_empty_vlen_unlim @@ -33,7 +32,7 @@ endif TESTS = $(NC4_TESTS) -TESTS += run_grp_rename.sh run_empty_vlen_test +TESTS += run_grp_rename.sh run_empty_vlen_test.sh # If the v2 API was built, add its test program. if BUILD_V2 From 7983e926a28e9e4b3fa3db470984e26cefda0ac2 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Fri, 19 Feb 2016 10:56:44 -0700 Subject: [PATCH 13/15] Updated release notes. --- RELEASE_NOTES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 5337ff15f..238740753 100755 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -5,6 +5,10 @@ Release Notes {#RELEASE_NOTES} This file contains a high-level description of this package's evolution. Releases are in reverse chronological order (most recent first). Note that, as of netcdf 4.2, the `netcdf-c++` and `netcdf-fortran` libraries have been separated into their own libraries. +## 4.4.1 - TBD + +* Addressed an issue where `ncdump` would crash when trying to read a netcdf file containing an empty ragged `VLEN` variable in an unlimited dimension. See [GitHub #221](https://github.com/Unidata/netcdf-c/issues/221) for more information. + ## 4.4.0 Released - January 13, 2016 * Bumped SO version to 11.0.0. From a75cb302dfb1caee922852b5b57fe797f4bae599 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Fri, 19 Feb 2016 11:06:56 -0700 Subject: [PATCH 14/15] Removed an error in nc_test4/Makefile.am --- nc_test4/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nc_test4/Makefile.am b/nc_test4/Makefile.am index 36c6bdcbf..0ce5717bc 100644 --- a/nc_test4/Makefile.am +++ b/nc_test4/Makefile.am @@ -21,7 +21,7 @@ tst_chunks tst_chunks2 tst_utf8 tst_fills tst_fills2 tst_fillbug \ tst_xplatform tst_xplatform2 tst_h_atts2 tst_endian_fill tst_atts \ t_type cdm_sea_soundings tst_camrun tst_vl tst_atts1 tst_atts2 \ tst_vars2 tst_files5 tst_files6 tst_sync tst_h_strbug tst_h_refs \ -tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite \ +tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite check_PROGRAMS = $(NC4_TESTS) renamegroup tst_empty_vlen_unlim From 5224607d7b029e425e7323549af955761271e0a0 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Fri, 19 Feb 2016 12:25:24 -0700 Subject: [PATCH 15/15] Deleted stray debugging file pre-merge. --- gdb.txt | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 gdb.txt diff --git a/gdb.txt b/gdb.txt deleted file mode 100644 index f1c255143..000000000 --- a/gdb.txt +++ /dev/null @@ -1,37 +0,0 @@ -set breakpoint pending on - -break nc4hdf.c:872 -command -watch provide_fill -c -end - -break vardata.c:473 -command -watch vals -end - - -break dumplib.c:1063 -command -print len -end - -break ncdump.c:1687 - -break nc4hdf.c:1126 - -run tst_empty_vlen_unlim.nc - -#---------- -# Solved first set of problems. On to second, in print_any_val. -#--------- -# - - - - -#break nc4hdf.c:974 -#command -#print fill_value_size -#end