diff options
author | Jonathan Kim <jkm@hdfgroup.org> | 2011-10-24 22:24:20 (GMT) |
---|---|---|
committer | Jonathan Kim <jkm@hdfgroup.org> | 2011-10-24 22:24:20 (GMT) |
commit | 1fde26b7a5447089ac57b2ffc10f2b535b7999de (patch) | |
tree | d6663401ce4b73e4a242d92fce0d25e7dd303a13 /tools/h5diff | |
parent | c7fe0c67adc04b108204af25c60449352b3a8e6b (diff) | |
download | hdf5-1fde26b7a5447089ac57b2ffc10f2b535b7999de.zip hdf5-1fde26b7a5447089ac57b2ffc10f2b535b7999de.tar.gz hdf5-1fde26b7a5447089ac57b2ffc10f2b535b7999de.tar.bz2 |
[svn-r21660] Purpose:
HDFFV-7770 - h5diff segmentation fault on JPSS files
Description:
Fixed segfault over non-comparable attribute with different dimention or
rank, along with '-c' option to display details.
Merged from HDF5 trunk r21658.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), Windows, Cmake
Diffstat (limited to 'tools/h5diff')
-rw-r--r-- | tools/h5diff/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tools/h5diff/h5diffgentest.c | 59 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_221.txt | 6 | ||||
-rw-r--r-- | tools/h5diff/testfiles/h5diff_222.txt | 6 | ||||
-rw-r--r-- | tools/h5diff/testfiles/non_comparables1.h5 | bin | 6408 -> 6568 bytes | |||
-rw-r--r-- | tools/h5diff/testfiles/non_comparables2.h5 | bin | 6408 -> 6584 bytes | |||
-rwxr-xr-x | tools/h5diff/testh5diff.sh | 3 |
7 files changed, 58 insertions, 17 deletions
diff --git a/tools/h5diff/CMakeLists.txt b/tools/h5diff/CMakeLists.txt index 3aa9a0e..cb5fa5f 100644 --- a/tools/h5diff/CMakeLists.txt +++ b/tools/h5diff/CMakeLists.txt @@ -1129,6 +1129,7 @@ ADD_H5_TEST (h5diff_208 0 -c ${FILE19} ${FILE20}) ADD_H5_TEST (h5diff_220 1 -c non_comparables1.h5 non_comparables2.h5 /g1) # comparable dataset with non-comparable attribute and other comparable attributes. +# Also test non-compatible attributes with different type, dimention, rank. # All the rest comparables should display differences. ADD_H5_TEST (h5diff_221 1 -c non_comparables1.h5 non_comparables2.h5 /g2) diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c index 206dca0..7ea9365 100644 --- a/tools/h5diff/h5diffgentest.c +++ b/tools/h5diff/h5diffgentest.c @@ -4700,9 +4700,14 @@ static void test_non_comparables (const char * fname, int make_diffs) hid_t sid1=0; hid_t tid_dset1=0; hid_t tid_attr1=0; - hsize_t dims1[1] = {DIM_ARRY}; + hsize_t dims1_1[1] = {DIM_ARRY}; + hsize_t dims1_2[1] = {DIM_ARRY+1}; + hsize_t dims2[2] = {DIM_ARRY, 1}; int data1[DIM_ARRY] = {0,0,0}; int data2[DIM_ARRY] = {1,1,1}; + int data3[DIM_ARRY+1] = {1,1,1,1}; + int data1_dim2[DIM_ARRY][1] = {0,0,0}; + int rank_attr; char data1_str[DIM_ARRY][STR_SIZE]= {"ab","cd","ef"}; herr_t status = SUCCEED; int i; @@ -4712,6 +4717,9 @@ static void test_non_comparables (const char * fname, int make_diffs) void *attr_data_ptr1=NULL; void *attr_data_ptr2=NULL; void *attr_data_ptr3=NULL; + void *attr_data_ptr4=NULL; + void *attr2_dim_ptr=NULL; + void *attr3_dim_ptr=NULL; /* init */ tid_dset1=H5Tcopy(H5T_NATIVE_INT); @@ -4721,6 +4729,10 @@ static void test_non_comparables (const char * fname, int make_diffs) tid_attr1=H5Tcopy(H5T_NATIVE_INT); attr_data_ptr1=(int*)&data1; attr_data_ptr3=(int*)&data1; + attr_data_ptr4=(int*)&data1; + attr2_dim_ptr=(hsize_t*)&dims1_1; + attr3_dim_ptr=(hsize_t*)&dims1_1; + rank_attr=1; if (make_diffs) { @@ -4736,12 +4748,22 @@ static void test_non_comparables (const char * fname, int make_diffs) * group2 */ dset_data_ptr3=(int*)&data2; - /* attr1 */ + /* dset1/attr1 */ tid_attr1=H5Tcopy(H5T_C_S1); H5Tset_size(tid_attr1, (size_t)STR_SIZE); attr_data_ptr2=(char*)&data1_str; - /* attr2 */ - attr_data_ptr3=(int*)&data2; + + /* dset1/attr2 */ + attr2_dim_ptr=(hsize_t*)&dims1_2; + + /* dset1/attr3 */ + attr_data_ptr3=(int*)&data1_dim2; + attr3_dim_ptr=(hsize_t*)&dims2; + rank_attr=2; + + /* dset1/attr4 */ + attr_data_ptr4=(int*)&data2; + } @@ -4778,7 +4800,7 @@ static void test_non_comparables (const char * fname, int make_diffs) /*----------------------------------------------------------------------- * Datasets in /g1 *------------------------------------------------------------------------*/ - if((sid1 = H5Screate_simple(1, dims1, NULL)) < 0) + if((sid1 = H5Screate_simple(1, dims1_1, NULL)) < 0) goto out; /* dset1 */ @@ -4795,10 +4817,10 @@ static void test_non_comparables (const char * fname, int make_diffs) status = FAIL; goto out; } - write_attr(did1,1,dims1,"attr", H5T_NATIVE_INT, attr_data_ptr1); + write_attr(did1,1,dims1_1,"attr", H5T_NATIVE_INT, attr_data_ptr1); /* dset2 */ - status = write_dset(gid1, 1, dims1,"dset2", H5T_NATIVE_INT, dset_data_ptr2); + status = write_dset(gid1, 1, dims1_1,"dset2", H5T_NATIVE_INT, dset_data_ptr2); if (status == FAIL) { fprintf(stderr, "Error: %s> write_dset failed\n", fname); @@ -4808,7 +4830,8 @@ static void test_non_comparables (const char * fname, int make_diffs) /*----------------------------------------------------------------------- * Datasets in /g2 *------------------------------------------------------------------------*/ - /* dset1 */ + /* --------- + * dset1 */ if((did2 = H5Dcreate2(gid2, "dset1", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { fprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", "dset1"); @@ -4822,14 +4845,22 @@ static void test_non_comparables (const char * fname, int make_diffs) status = FAIL; goto out; } - /* attr1 */ - write_attr(did2,1,dims1,"attr1", tid_attr1, attr_data_ptr2); + /* attr1 - non-compatible : different type */ + write_attr(did2,1,dims1_1,"attr1", tid_attr1, attr_data_ptr2); - /* attr2 */ - write_attr(did2,1,dims1,"attr2", H5T_NATIVE_INT, attr_data_ptr3); - /* dset2 */ - status = write_dset(gid2, 1, dims1,"dset2", H5T_NATIVE_INT, dset_data_ptr3); + /* attr2 - non-compatible : same rank, different dimention */ + write_attr(did2,1, attr2_dim_ptr,"attr2", H5T_NATIVE_INT, data3); + + /* attr3 - non-compatible : different rank */ + write_attr(did2, rank_attr,attr3_dim_ptr,"attr3", H5T_NATIVE_INT, attr_data_ptr3); + + /* attr4 - compatible : different data values */ + write_attr(did2,1,dims1_1,"attr4", H5T_NATIVE_INT, attr_data_ptr4); + + /*---------- + * dset2 */ + status = write_dset(gid2, 1, dims1_1,"dset2", H5T_NATIVE_INT, dset_data_ptr3); if (status == FAIL) { fprintf(stderr, "Error: %s> write_dset failed\n", fname); diff --git a/tools/h5diff/testfiles/h5diff_221.txt b/tools/h5diff/testfiles/h5diff_221.txt index 8f90300..621f5c3 100644 --- a/tools/h5diff/testfiles/h5diff_221.txt +++ b/tools/h5diff/testfiles/h5diff_221.txt @@ -1,5 +1,9 @@ Not comparable: <attr1> is of class H5T_INTEGER and <attr1> is of class H5T_STRING -attribute: <attr2 of </g2/dset1>> and <attr2 of </g2/dset1>> +Not comparable: <attr2> has rank 1, dimensions [3], max dimensions [3] +and <attr2> has rank 1, dimensions [4], max dimensions [4] +Not comparable: <attr3> has rank 1, dimensions [3], max dimensions [3] +and <attr3> has rank 2, dimensions [3x1], max dimensions [3x1] +attribute: <attr4 of </g2/dset1>> and <attr4 of </g2/dset1>> 3 differences found dataset: </g2/dset1> and </g2/dset1> 6 differences found diff --git a/tools/h5diff/testfiles/h5diff_222.txt b/tools/h5diff/testfiles/h5diff_222.txt index 6e1bbd4..bdecb8a 100644 --- a/tools/h5diff/testfiles/h5diff_222.txt +++ b/tools/h5diff/testfiles/h5diff_222.txt @@ -6,7 +6,11 @@ dataset: </g1/dset1> and </g1/dset1> dataset: </g1/dset2> and </g1/dset2> 3 differences found Not comparable: <attr1> is of class H5T_INTEGER and <attr1> is of class H5T_STRING -attribute: <attr2 of </g2/dset1>> and <attr2 of </g2/dset1>> +Not comparable: <attr2> has rank 1, dimensions [3], max dimensions [3] +and <attr2> has rank 1, dimensions [4], max dimensions [4] +Not comparable: <attr3> has rank 1, dimensions [3], max dimensions [3] +and <attr3> has rank 2, dimensions [3x1], max dimensions [3x1] +attribute: <attr4 of </g2/dset1>> and <attr4 of </g2/dset1>> 3 differences found dataset: </g2/dset1> and </g2/dset1> 6 differences found diff --git a/tools/h5diff/testfiles/non_comparables1.h5 b/tools/h5diff/testfiles/non_comparables1.h5 Binary files differindex 3aa5199..71b65c8 100644 --- a/tools/h5diff/testfiles/non_comparables1.h5 +++ b/tools/h5diff/testfiles/non_comparables1.h5 diff --git a/tools/h5diff/testfiles/non_comparables2.h5 b/tools/h5diff/testfiles/non_comparables2.h5 Binary files differindex d860625..188ceb9 100644 --- a/tools/h5diff/testfiles/non_comparables2.h5 +++ b/tools/h5diff/testfiles/non_comparables2.h5 diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh index 74ecd3a..8de12a5 100755 --- a/tools/h5diff/testh5diff.sh +++ b/tools/h5diff/testh5diff.sh @@ -799,7 +799,8 @@ TOOLTEST h5diff_207.txt -c h5diff_basic2.h5 h5diff_basic2.h5 g2/dset8 g2/dset9 # not comparable in dataspace of zero dimension size TOOLTEST h5diff_208.txt -c h5diff_dset_zero_dim_size1.h5 h5diff_dset_zero_dim_size2.h5 -# non-comparable dataset with comparable attribute, and other comparable datasets. +# non-comparable dataset with comparable attribute, and other comparable datasets. +# Also test non-compatible attributes with different type, dimention, rank. # All the comparables should display differences. TOOLTEST h5diff_220.txt -c non_comparables1.h5 non_comparables2.h5 /g1 |