From d174933e1953dc11a32a4715beec166a2490487f Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Thu, 5 Jan 2012 10:16:03 -0500 Subject: [svn-r21865] Purpose: Fix for HDFFV-7838 h5ls: segfault for handling region reference in attribute with -v option Description: Segfault occurred when h5ls access region reference data in an attribute. This didn't occurred when -v option was used. The cause was "h5tool_format_t info;" struct variable members were accessed without proper values were assigned (was NULL), so printf failed later in the code. Tested: jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake-Windows (32-LE) --- MANIFEST | 2 ++ release_docs/RELEASE.txt | 2 ++ tools/h5ls/CMakeLists.txt | 21 ++++++++++++++++++--- tools/h5ls/h5ls.c | 8 +++++++- tools/h5ls/testh5ls.sh.in | 11 +++++++++++ tools/testfiles/tattrreg_be.ls | 25 +++++++++++++++++++++++++ tools/testfiles/tattrreg_le.ls | 25 +++++++++++++++++++++++++ 7 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 tools/testfiles/tattrreg_be.ls create mode 100644 tools/testfiles/tattrreg_le.ls diff --git a/MANIFEST b/MANIFEST index 811b3b6..fd79de8 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1579,6 +1579,8 @@ ./tools/testfiles/tsaf.ls ./tools/testfiles/tstr-1.ls ./tools/testfiles/tattr2.ls +./tools/testfiles/tattrreg_le.ls +./tools/testfiles/tattrreg_be.ls ./tools/testfiles/tvldtypes1.ls ./tools/testfiles/tvldtypes2le.ls ./tools/testfiles/tvldtypes2be.ls diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 14dec2c..16b41d0 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -632,6 +632,8 @@ Bug Fixes since HDF5-1.8.0 release Tools ----- + - h5ls: fixed segfault when access region reference data in an + attribute. (JKM 2011/12/29) - h5diff: fixed segfault over non-comparable attribute with different dimention or rank, along with '-c' option to display details. HDFFV-7770 (JKM 2011/10/24) diff --git a/tools/h5ls/CMakeLists.txt b/tools/h5ls/CMakeLists.txt index 2bbe088..ad37da0 100644 --- a/tools/h5ls/CMakeLists.txt +++ b/tools/h5ls/CMakeLists.txt @@ -38,6 +38,8 @@ IF (BUILD_TESTING) tall-2.ls tarray1.ls tattr2.ls + tattrreg_le.ls + tattrreg_be.ls tcomp-1.ls tdataregbe.ls tdataregle.ls @@ -88,6 +90,7 @@ IF (BUILD_TESTING) tall.h5 tarray1.h5 tattr2.h5 + tattrreg.h5 tcompound.h5 tdatareg.h5 tdset.h5 @@ -395,16 +398,28 @@ IF (BUILD_TESTING) # enable -S for avoiding printing NATIVE types ADD_H5_TEST (tattr2 0 -w80 -v -S tattr2.h5) + # test for attribute with region references wo verbose mode + # ( HDFFV-7838, ) + IF (H5_WORDS_BIGENDIAN) + ADD_H5_TEST (tattrreg_be 0 -w80 -v -d tattrreg.h5) + ELSE (H5_WORDS_BIGENDIAN) + ADD_H5_TEST (tattrreg_le 0 -w80 -v -d tattrreg.h5) + ENDIF (H5_WORDS_BIGENDIAN) + # test for non-existing file ADD_H5_TEST (nosuchfile 1 nosuchfile.h5) + # test for variable length data types in verbose mode IF (H5_WORDS_BIGENDIAN) - # test for variable length data types in verbose mode ADD_H5_TEST (tvldtypes2be 0 -v tvldtypes1.h5) - # test for dataset region references data types in verbose mode - ADD_H5_TEST (tdataregbe 0 -v tdatareg.h5) ELSE (H5_WORDS_BIGENDIAN) ADD_H5_TEST (tvldtypes2le 0 -v tvldtypes1.h5) + ENDIF (H5_WORDS_BIGENDIAN) + + # test for dataset region references data types in verbose mode + IF (H5_WORDS_BIGENDIAN) + ADD_H5_TEST (tdataregbe 0 -v tdatareg.h5) + ELSE (H5_WORDS_BIGENDIAN) ADD_H5_TEST (tdataregle 0 -v tdatareg.h5) ENDIF (H5_WORDS_BIGENDIAN) diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index a00a9e1..66e588f 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -1447,9 +1447,15 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo, info.line_suf = "\""; } /* end if */ - /* values of type reference */ + /* values of reference type formats */ + info.dset_format = "DSET-%s "; + info.dset_hidefileno = 1; + info.dset_blockformat_pre = "%sBlk%lu: "; + info.dset_ptformat_pre = "%sPt%lu: "; + info.obj_format = "-%lu:"H5_PRINTF_HADDR_FMT; info.obj_hidefileno = 0; + if(hexdump_g) p_type = H5Tcopy(type); else diff --git a/tools/h5ls/testh5ls.sh.in b/tools/h5ls/testh5ls.sh.in index bdf0af7..e2c204b 100644 --- a/tools/h5ls/testh5ls.sh.in +++ b/tools/h5ls/testh5ls.sh.in @@ -65,6 +65,7 @@ LIST_HDF5_TEST_FILES=" $SRC_H5LS_TESTFILES/tall.h5 $SRC_H5LS_TESTFILES/tarray1.h5 $SRC_H5LS_TESTFILES/tattr2.h5 +$SRC_H5LS_TESTFILES/tattrreg.h5 $SRC_H5LS_TESTFILES/tcompound.h5 $SRC_H5LS_TESTFILES/tdatareg.h5 $SRC_H5LS_TESTFILES/tdset.h5 @@ -94,6 +95,8 @@ $SRC_H5LS_TESTFILES/tall-1.ls $SRC_H5LS_TESTFILES/tall-2.ls $SRC_H5LS_TESTFILES/tarray1.ls $SRC_H5LS_TESTFILES/tattr2.ls +$SRC_H5LS_TESTFILES/tattrreg_le.ls +$SRC_H5LS_TESTFILES/tattrreg_be.ls $SRC_H5LS_TESTFILES/tcomp-1.ls $SRC_H5LS_TESTFILES/tdataregbe.ls $SRC_H5LS_TESTFILES/tdataregle.ls @@ -357,6 +360,14 @@ TOOLTEST tempty.ls 0 -w80 -d tempty.h5 # enable -S for avoiding printing NATIVE types TOOLTEST tattr2.ls 0 -w80 -v -S tattr2.h5 +# test for attribute with region references without verbose mode +# ( HDFFV-7838, ) +if test $WORDS_BIGENDIAN != "yes"; then +TOOLTEST tattrreg_le.ls 0 -w80 -v -d tattrreg.h5 +else +TOOLTEST tattrreg_be.ls 0 -w80 -v -d tattrreg.h5 +fi + # tests for error handling. # test for non-existing file TOOLTEST nosuchfile.ls 1 nosuchfile.h5 diff --git a/tools/testfiles/tattrreg_be.ls b/tools/testfiles/tattrreg_be.ls new file mode 100644 index 0000000..46b30ac --- /dev/null +++ b/tools/testfiles/tattrreg_be.ls @@ -0,0 +1,25 @@ +Opened "tattrreg.h5" with sec2 driver. +Dataset1 Dataset {NULL} + Attribute: Attribute1 {4} + Type: dataset region reference + Data: DSET-/Dataset2 {Blk0: (2,2)-(7,7)}, DSET-/Dataset2 {Pt0: (6,9), + Pt1: (2,2), Pt2: (8,4), Pt3: (1,6), Pt4: (2,8), Pt5: (3,2), + Pt6: (0,4), Pt7: (9,0), Pt8: (7,1), Pt9: (3,3)}, NULL, NULL + Location: 1:1400 + Links: 1 + Storage: 0 logical bytes, 0 allocated bytes + Type: 32-bit little-endian integer + Data: +Dataset2 Dataset {10/10, 10/10} + Location: 1:800 + Links: 1 + Storage: 100 logical bytes, 100 allocated bytes, 100.00% utilization + Type: native unsigned char + Data: + (0,0) 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, + (1,7) 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, + (3,3) 99, 102, 105, 108, 111, 114, 117, 120, 123, 126, 129, 132, 135, + (4,6) 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, + (5,9) 177, 180, 183, 186, 189, 192, 195, 198, 201, 204, 207, 210, 213, + (7,2) 216, 219, 222, 225, 228, 231, 234, 237, 240, 243, 246, 249, 252, + (8,5) 255, 2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41 diff --git a/tools/testfiles/tattrreg_le.ls b/tools/testfiles/tattrreg_le.ls new file mode 100644 index 0000000..2eafc07 --- /dev/null +++ b/tools/testfiles/tattrreg_le.ls @@ -0,0 +1,25 @@ +Opened "tattrreg.h5" with sec2 driver. +Dataset1 Dataset {NULL} + Attribute: Attribute1 {4} + Type: dataset region reference + Data: DSET-/Dataset2 {Blk0: (2,2)-(7,7)}, DSET-/Dataset2 {Pt0: (6,9), + Pt1: (2,2), Pt2: (8,4), Pt3: (1,6), Pt4: (2,8), Pt5: (3,2), + Pt6: (0,4), Pt7: (9,0), Pt8: (7,1), Pt9: (3,3)}, NULL, NULL + Location: 1:1400 + Links: 1 + Storage: 0 logical bytes, 0 allocated bytes + Type: native int + Data: +Dataset2 Dataset {10/10, 10/10} + Location: 1:800 + Links: 1 + Storage: 100 logical bytes, 100 allocated bytes, 100.00% utilization + Type: 8-bit unsigned integer + Data: + (0,0) 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, + (1,7) 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, + (3,3) 99, 102, 105, 108, 111, 114, 117, 120, 123, 126, 129, 132, 135, + (4,6) 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, + (5,9) 177, 180, 183, 186, 189, 192, 195, 198, 201, 204, 207, 210, 213, + (7,2) 216, 219, 222, 225, 228, 231, 234, 237, 240, 243, 246, 249, 252, + (8,5) 255, 2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41 -- cgit v0.12