summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2011-07-18 23:16:08 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2011-07-18 23:16:08 (GMT)
commit99992db34d0384895abfd8aeeb5b2d5202a91c07 (patch)
tree07ce97b278519d3a9efa49307e13a11910486a7a
parent28b4826a812c193b94b8d43b91fb3048d97d2eb5 (diff)
downloadhdf5-99992db34d0384895abfd8aeeb5b2d5202a91c07.zip
hdf5-99992db34d0384895abfd8aeeb5b2d5202a91c07.tar.gz
hdf5-99992db34d0384895abfd8aeeb5b2d5202a91c07.tar.bz2
[svn-r21122] Description:
Bring r21120 from trunk to 1.8 branch: Check in ugly version of fix for Jira #7638. I'm going to leave the issue open in Jira and when the library has been refactored to use shared file pointers (instead of top file pointers) for file operations, I'll uncomment the check in src/H5Oshared.c Tested on: Mac OS X/32 10.6.8 (amazon) w/debug (too small for h5committest)
-rw-r--r--release_docs/RELEASE.txt4
-rw-r--r--src/H5Oshared.c17
-rw-r--r--test/Makefile.am2
-rw-r--r--test/Makefile.in2
-rw-r--r--test/dtypes.c199
5 files changed, 218 insertions, 6 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 4d79f70..78e365e 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -109,6 +109,10 @@ Bug Fixes since HDF5-1.8.7
Library
-------
+ - Corrected internal error in library where objects that use named
+ datatypes and were accessed from two different file IDs could confuse
+ the two and cause erroneous failures. This addresses Jira issue #7638.
+ (QAK - 2011/07/18)
- In v1.6 library, there was EOA for the whole MULTI file saved in the
super block. We took it out in v1.8 library because it's meaningless
for the MULTI file. v1.8 library saves the EOA for the metadata file,
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index a5e3efc..6e2beca 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -243,8 +243,17 @@ H5O_shared_link_adj(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
* new object header. Adjust the reference count on that
* object header.
*/
- if(shared->file->shared != f->shared)
- HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "interfile hard links are not allowed")
+ /* Unfortunately, it is possible for the shared->file pointer to become
+ * invalid if the oh is kept in cache (which is contained in
+ * shared->file->shared while shared->file is closed. Just ignore
+ * shared->file until the "top-level" file pointer is removed at some
+ * point in the future. -NAF */
+ /* This is related to Jira issue #7638 and should be uncommented after
+ * the library has been refactored to shift to using shared file
+ * pointers for file operations, instead of using top file pointers.
+ * -QAK */
+ /*if(shared->file->shared != f->shared)
+ HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "interfile hard links are not allowed")*/
/* Build the object location for the shared message's object header */
oloc.file = f;
@@ -579,7 +588,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5O_shared_copy_file(H5F_t UNUSED *file_src, H5F_t *file_dst,
+H5O_shared_copy_file(H5F_t *file_src, H5F_t *file_dst,
const H5O_msg_class_t *mesg_type, const void *_native_src, void *_native_dst,
hbool_t UNUSED *recompute_size, H5O_copy_t *cpy_info, void UNUSED *udata,
hid_t dxpl_id)
@@ -610,7 +619,7 @@ H5O_shared_copy_file(H5F_t UNUSED *file_src, H5F_t *file_dst,
/* Copy the shared object from source to destination */
dst_oloc.file = file_dst;
- src_oloc.file = shared_src->file;
+ src_oloc.file = file_src;
src_oloc.addr = shared_src->u.loc.oh_addr;
if(H5O_copy_header_map(&src_oloc, &dst_oloc, dxpl_id, cpy_info, FALSE,
NULL, NULL) < 0)
diff --git a/test/Makefile.am b/test/Makefile.am
index 52283bd..50bbe5b 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -111,7 +111,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse
stab.h5 extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 \
dt_arith[1-2] links.h5 links[0-6]*.h5 extlinks[0-15].h5 tmp \
big.data big[0-9][0-9][0-9][0-9][0-9].h5 \
- stdio.h5 sec2.h5 dtypes[1-8].h5 dt_arith[1-2].h5 tattr.h5 \
+ stdio.h5 sec2.h5 dtypes[0-9].h5 dt_arith[1-2].h5 tattr.h5 \
tselect.h5 mtime.h5 unlink.h5 unicode.h5 coord.h5 \
fillval_[0-9].h5 fillval.raw mount_[0-9].h5 testmeta.h5 ttime.h5 \
trefer[1-3].h5 tvltypes.h5 tvlstr.h5 tvlstr2.h5 flush.h5 \
diff --git a/test/Makefile.in b/test/Makefile.in
index 1021c14..222dd42 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -722,7 +722,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog accum.h5 cmpd_dset.h5 \
extern_[1-4][ab].raw gheap[0-4].h5 dt_arith[1-2] links.h5 \
links[0-6]*.h5 extlinks[0-15].h5 tmp big.data \
big[0-9][0-9][0-9][0-9][0-9].h5 stdio.h5 sec2.h5 \
- dtypes[1-8].h5 dt_arith[1-2].h5 tattr.h5 tselect.h5 mtime.h5 \
+ dtypes[0-9].h5 dt_arith[1-2].h5 tattr.h5 tselect.h5 mtime.h5 \
unlink.h5 unicode.h5 coord.h5 fillval_[0-9].h5 fillval.raw \
mount_[0-9].h5 testmeta.h5 ttime.h5 trefer[1-3].h5 tvltypes.h5 \
tvlstr.h5 tvlstr2.h5 flush.h5 enum1.h5 titerate.h5 ttsafe.h5 \
diff --git a/test/dtypes.c b/test/dtypes.c
index 54aebcc..184cbf7 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -71,6 +71,7 @@
}
const char *FILENAME[] = {
+ "dtypes0",
"dtypes1",
"dtypes2",
"dtypes3",
@@ -79,6 +80,7 @@ const char *FILENAME[] = {
"dtypes6",
"dtypes7",
"dtypes8",
+ "dtypes9",
NULL
};
@@ -102,6 +104,11 @@ typedef enum dtype_t {
#define COMPOUND13_ARRAY_SIZE 256
#define COMPOUND13_ATTR_NAME "attr"
+/* Constants for delete_obj_named test */
+#define DEL_OBJ_NAMED_DATASET "/Dataset"
+#define DEL_OBJ_NAMED_NAMED_DTYPE "/Dtype"
+#define DEL_OBJ_NAMED_ATTRIBUTE "Attr"
+
/* Count opaque conversions */
static int num_opaque_conversions_g = 0;
@@ -6612,6 +6619,197 @@ error:
return 1;
} /* end test_named_indirect_reopen() */
+static void create_del_obj_named_test_file(const char *filename, hid_t fapl,
+ hbool_t new_format)
+{
+ hid_t file; /* File ID */
+ hid_t type; /* Datatype ID */
+ hid_t space; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dset; /* Dataset ID */
+ hid_t fcpl; /* File creation property list ID */
+ hid_t my_fapl; /* Copy of file access property list ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ herr_t status; /* Generic return value */
+
+ /* Make copy of FAPL */
+ my_fapl = H5Pcopy(fapl);
+ assert(my_fapl > 0);
+
+ if(new_format) {
+ /* Use latest version of file format */
+ status = H5Pset_libver_bounds(my_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
+ assert(status >= 0);
+ } /* end if */
+
+ /* Create a file creation property list (used for the root group's creation property list) */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ assert(fcpl > 0);
+
+ if(new_format) {
+ /* Use dense link storage for all links in root group */
+ status = H5Pset_link_phase_change(fcpl, 0, 0);
+ assert(status >= 0);
+ } /* end if */
+
+ /* Create file with attribute that uses committed datatype */
+ file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, my_fapl);
+ assert(file > 0);
+
+ /* Close FCPL */
+ status = H5Pclose(fcpl);
+ assert(status >= 0);
+
+ /* Close FAPL */
+ status = H5Pclose(my_fapl);
+ assert(status >= 0);
+
+ /* Create datatype to commit */
+ type = H5Tvlen_create(H5T_NATIVE_INT);
+ assert(type > 0);
+
+ /* Commit datatype */
+ status = H5Tcommit2(file, DEL_OBJ_NAMED_NAMED_DTYPE, type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ assert(status >= 0);
+
+ /* Create scalar dataspace */
+ space = H5Screate(H5S_SCALAR);
+ assert(space > 0);
+
+ /* Create a dataset creation property list */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ assert(dcpl > 0);
+
+ if(new_format) {
+ /* Use dense attribute storage for all attributes on dataset */
+ status = H5Pset_attr_phase_change(dcpl, 0, 0);
+ assert(status >= 0);
+ } /* end if */
+
+ /* Create dataset */
+ dset = H5Dcreate2(file, DEL_OBJ_NAMED_DATASET, type, space, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ assert(dset > 0);
+
+ /* Close DCPL */
+ status = H5Pclose(dcpl);
+ assert(status >= 0);
+
+ /* Close dataset */
+ status = H5Dclose(dset);
+ assert(status >= 0);
+
+ /* Create attribute */
+ attr = H5Acreate_by_name(file, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ assert(attr > 0);
+
+ /* Close dataspace */
+ status = H5Sclose(space);
+ assert(status >= 0);
+
+ /* Close datatype */
+ status = H5Tclose(type);
+ assert(status >= 0);
+
+ /* Close attribute */
+ status = H5Aclose(attr);
+ assert(status >= 0);
+
+ /* Close file */
+ status = H5Fclose(file);
+ assert(status >= 0);
+} /* end create_del_obj_named_test_file() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_delete_obj_named
+ *
+ * Purpose: Tests that delete objects that use named datatypes through
+ * different file IDs
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Quincey Koziol
+ * Monday, July 18, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_delete_obj_named(hid_t fapl)
+{
+ hid_t filea1 = -1, filea2 = -1, fileb = -1; /* File IDs */
+ hid_t attr = -1; /* Attribute ID */
+ hid_t dset = -1; /* Dataset ID */
+ hid_t fapl2 = -1; /* File access property list ID */
+ hbool_t new_format; /* Whether to use old or new format */
+ char filename[1024], filename2[1024];
+
+ TESTING("deleting objects that use named datatypes");
+
+ /* Set up filenames & FAPLs */
+ if((fapl2 = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR
+ h5_fixname(FILENAME[8], fapl, filename, sizeof filename);
+ h5_fixname(FILENAME[9], fapl2, filename2, sizeof filename2);
+
+ /* Loop over old & new format files */
+ for(new_format = FALSE; new_format <= TRUE; new_format++) {
+ /* Create test file, with attribute that uses committed datatype */
+ create_del_obj_named_test_file(filename, fapl, new_format);
+
+/* Test deleting dataset opened through different file ID */
+ if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ if((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
+
+ if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR
+
+ if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR
+
+ if(H5Ldelete(filea2, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+
+ if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR
+
+
+ /* Create test file, with attribute that uses committed datatype */
+ create_del_obj_named_test_file(filename, fapl, new_format);
+
+/* Test deleting attribute opened through different file ID */
+ if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ if((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Aclose(attr) < 0) FAIL_STACK_ERROR
+
+ if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR
+
+ if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR
+
+ if(H5Adelete_by_name(filea2, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+
+ if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR
+ } /* end for */
+
+ if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Tclose(attr);
+ H5Dclose(dset);
+ H5Pclose(fapl2);
+ H5Fclose(filea1);
+ H5Fclose(filea2);
+ H5Fclose(fileb);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_delete_obj_named() */
+
/*-------------------------------------------------------------------------
* Function: test_deprec
@@ -6806,6 +7004,7 @@ main(void)
nerrors += test_latest();
nerrors += test_int_float_except();
nerrors += test_named_indirect_reopen(fapl);
+ nerrors += test_delete_obj_named(fapl);
nerrors += test_set_order_compound(fapl);
nerrors += test_str_create();
#ifndef H5_NO_DEPRECATED_SYMBOLS