summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2019-03-15 17:02:13 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2019-03-15 17:02:13 (GMT)
commitcac673138c94cdbd5faa227fe5a9867941753c93 (patch)
tree4c71b0f8423afc86ec8cb2b706120f0884298338 /src
parent79f9b443dae87482326bb9a37a1a8070c1f8669d (diff)
parent4daf6b110d2a161f66d6812c4d33cafdbf6147c9 (diff)
downloadhdf5-cac673138c94cdbd5faa227fe5a9867941753c93.zip
hdf5-cac673138c94cdbd5faa227fe5a9867941753c93.tar.gz
hdf5-cac673138c94cdbd5faa227fe5a9867941753c93.tar.bz2
Merge pull request #1603 in HDFFV/hdf5 from ~NFORTNE2/hdf5_naf:hdf5_1_8 to hdf5_1_8
Merge pull request 1448 and related pull requests to 1.8 branch * commit '4daf6b110d2a161f66d6812c4d33cafdbf6147c9': Add RELEASE.txt note for unknown message fix (pull request 1448) Remove H5O_BOGUS_INVALID_ID from H5O_msg_class_g initialization, since space for it was removed. Delay checking if decoded message's "shareable" flag is appropriate for the message type until we've verified we understand the message type. Reduce size of H5O_msg_class_g to *not* include space for H5O_BOGUS_INVALID. Make bogus messages shareable. Add new bogus message test with shareable messages to cover the formerly problematic code. Re-run gen_bogus.c to add this test case and also to fix the bogus_invalid messages that were no longer H5O_BOGUS_INVLAID due to a new message class being added in a previous commit. Added comment to remind developers to run gen_bogus.c when adding a new message class.
Diffstat (limited to 'src')
-rw-r--r--src/H5O.c7
-rw-r--r--src/H5Obogus.c4
-rw-r--r--src/H5Ocache.c17
-rw-r--r--src/H5Omessage.c25
-rw-r--r--src/H5Opkg.h2
-rw-r--r--src/H5Oprivate.h3
6 files changed, 34 insertions, 24 deletions
diff --git a/src/H5O.c b/src/H5O.c
index 70585a7..4df72ec 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -123,12 +123,7 @@ const H5O_msg_class_t *const H5O_msg_class_g[] = {
H5O_MSG_DRVINFO, /*0x0014 Driver info settings */
H5O_MSG_AINFO, /*0x0015 Attribute information */
H5O_MSG_REFCOUNT, /*0x0016 Object's ref. count */
- H5O_MSG_UNKNOWN, /*0x0017 Placeholder for unknown message */
-#ifdef H5O_ENABLE_BOGUS
- H5O_MSG_BOGUS_INVALID /*0x0018 "Bogus invalid" (for testing) */
-#else /* H5O_ENABLE_BOGUS */
- NULL /*0x0018 "Bogus invalid" (for testing) */
-#endif /* H5O_ENABLE_BOGUS */
+ H5O_MSG_UNKNOWN /*0x0017 Placeholder for unknown message */
};
/* Declare a free list to manage the H5O_t struct */
diff --git a/src/H5Obogus.c b/src/H5Obogus.c
index ba9a8ad..bf002ea 100644
--- a/src/H5Obogus.c
+++ b/src/H5Obogus.c
@@ -48,7 +48,7 @@ const H5O_msg_class_t H5O_MSG_BOGUS_VALID[1] = {{
H5O_BOGUS_VALID_ID, /*message id number */
"bogus valid", /*message name for debugging */
0, /*native message size */
- 0, /*messages are sharable? */
+ H5O_SHARE_IS_SHARABLE, /*messages are sharable? */
H5O_bogus_decode, /*decode message */
H5O_bogus_encode, /*encode message */
NULL, /*copy the native value */
@@ -72,7 +72,7 @@ const H5O_msg_class_t H5O_MSG_BOGUS_INVALID[1] = {{
H5O_BOGUS_INVALID_ID, /*message id number */
"bogus invalid", /*message name for debugging */
0, /*native message size */
- 0, /*messages are sharable? */
+ H5O_SHARE_IS_SHARABLE, /*messages are sharable? */
H5O_bogus_decode, /*decode message */
H5O_bogus_encode, /*encode message */
NULL, /*copy the native value */
diff --git a/src/H5Ocache.c b/src/H5Ocache.c
index 39f3ca3..8e7690e 100644
--- a/src/H5Ocache.c
+++ b/src/H5Ocache.c
@@ -1128,10 +1128,9 @@ H5O_chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image,
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "bad flag combination for message")
if((flags & H5O_MSG_FLAG_WAS_UNKNOWN) && !(flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN))
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "bad flag combination for message")
- if((flags & H5O_MSG_FLAG_SHAREABLE)
- && H5O_msg_class_g[id]
- && !(H5O_msg_class_g[id]->share_flags & H5O_SHARE_IS_SHARABLE))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "message of unsharable class flagged as sharable")
+ /* Delay checking the "shareable" flag until we've made sure id
+ * references a valid message class that this version of the library
+ * knows about */
/* Reserved bytes/creation index */
if(oh->version == H5O_VERSION_1)
@@ -1236,9 +1235,17 @@ H5O_chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image,
*dirty = TRUE;
} /* end if */
} /* end if */
- else
+ else {
+ /* Check for message of unshareable class marked as "shareable"
+ */
+ if((flags & H5O_MSG_FLAG_SHAREABLE)
+ && H5O_msg_class_g[id]
+ && !(H5O_msg_class_g[id]->share_flags & H5O_SHARE_IS_SHARABLE))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "message of unshareable class flagged as shareable")
+
/* Set message class for "known" messages */
oh->mesg[mesgno].type = H5O_msg_class_g[id];
+ } /* end else */
} /* end else */
/* Advance decode pointer past message */
diff --git a/src/H5Omessage.c b/src/H5Omessage.c
index a2e4e88..970fda6 100644
--- a/src/H5Omessage.c
+++ b/src/H5Omessage.c
@@ -1615,16 +1615,23 @@ H5O_msg_is_shared(unsigned type_id, const void *mesg)
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Check args */
- HDassert(type_id < NELMTS(H5O_msg_class_g));
- type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
- HDassert(type);
- HDassert(mesg);
-
- /* If messages in a class aren't sharable, then obviously this message isn't shared! :-) */
- if(type->share_flags & H5O_SHARE_IS_SHARABLE)
- ret_value = H5O_IS_STORED_SHARED(((const H5O_shared_t *)mesg)->type);
- else
+#ifdef H5O_ENABLE_BOGUS
+ if(type_id >= NELMTS(H5O_msg_class_g))
ret_value = FALSE;
+ else
+#endif /* H5O_ENABLE_BOGUS */
+ {
+ HDassert(type_id < NELMTS(H5O_msg_class_g));
+ type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
+ HDassert(type);
+ HDassert(mesg);
+
+ /* If messages in a class aren't sharable, then obviously this message isn't shared! :-) */
+ if(type->share_flags & H5O_SHARE_IS_SHARABLE)
+ ret_value = H5O_IS_STORED_SHARED(((const H5O_shared_t *)mesg)->type);
+ else
+ ret_value = FALSE;
+ } /* end block/else */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_msg_is_shared() */
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index f4b8014..8077be9 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -29,7 +29,7 @@
#define H5O_NMESGS 8 /*initial number of messages */
#define H5O_NCHUNKS 2 /*initial number of chunks */
#define H5O_MIN_SIZE 22 /* Min. obj header data size (must be big enough for a message prefix and a continuation message) */
-#define H5O_MSG_TYPES 25 /* # of types of messages */
+#define H5O_MSG_TYPES 24 /* # of types of messages */
#define H5O_MAX_CRT_ORDER_IDX 65535 /* Max. creation order index value */
/* Versions of object header structure */
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 1f51705..5e806cd 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -205,7 +205,7 @@ typedef struct H5O_copy_t {
* Note: Must increment H5O_MSG_TYPES in H5Opkg.h and update H5O_msg_class_g
* in H5O.c when creating a new message type. Also bump the value of
* H5O_BOGUS_INVALID_ID, below, to be one greater than the value of
- * H5O_UNKNOWN_ID.
+ * H5O_UNKNOWN_ID, and re-run gen_bogus.c.
*
* (this should never exist in a file)
*/
@@ -448,6 +448,7 @@ typedef struct H5O_layout_t {
*/
#define H5O_BOGUS_VALUE 0xdeadbeef
typedef struct H5O_bogus_t {
+ H5O_shared_t sh_loc; /* Shared message info (must be first) */
unsigned u; /* Hold the bogus info */
} H5O_bogus_t;
#endif /* H5O_ENABLE_BOGUS */