summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2010-10-11 22:15:54 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2010-10-11 22:15:54 (GMT)
commit233741567405cb6a983399b19ae298fd9211e124 (patch)
treeb66bc71f7fde9dc125718b58978b6eb85b1bbc78 /src
parent293e541644a9c5bc98067d8050f70c8e629eea5d (diff)
parent9df4fe0a8787dd2e7a24c0b8fa5624dc00a18676 (diff)
downloadhdf5-233741567405cb6a983399b19ae298fd9211e124.zip
hdf5-233741567405cb6a983399b19ae298fd9211e124.tar.gz
hdf5-233741567405cb6a983399b19ae298fd9211e124.tar.bz2
[svn-r19578] Bug fix for 1707 - H5Eset_auto causes a seg fault when an application uses -DH5_USE_16_API
with the 1.8 library to compile. The cause is from the mismatch of H5Eprint1 and H5Eprint2 set through H5Eset_auto. I changed the structure H5E_auto_t. I added a IS_DEDAULT flag in it. Both H5Eprint1/2 are the default now. If the user sets his/her own printing function. Then a call to H5Eget_auto1/2 will have to match H5Eset_auto1/2. Tested on heiwa, jam, and amani. The property change in configure.in, config, and Makefile.am came from the merge of the 1.8 library change.
Diffstat (limited to 'src')
-rw-r--r--src/H5E.c51
-rw-r--r--src/H5Edeprec.c26
-rw-r--r--src/H5Eint.c18
-rw-r--r--src/H5Epkg.h19
4 files changed, 92 insertions, 22 deletions
diff --git a/src/H5E.c b/src/H5E.c
index 01dd35b..8b6afc5 100644
--- a/src/H5E.c
+++ b/src/H5E.c
@@ -170,13 +170,21 @@ H5E_set_default_auto(H5E_t *stk)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_set_default_auto)
-#ifdef H5_USE_16_API
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+#ifdef H5_USE_16_API_DEFAULT
stk->auto_op.vers = 1;
stk->auto_op.u.func1 = (H5E_auto1_t)H5Eprint1;
#else /* H5_USE_16_API */
stk->auto_op.vers = 2;
- stk->auto_op.u.func2 = (H5E_auto2_t)H5Eprint2;
-#endif /* H5_USE_16_API */
+#endif /* H5_USE_16_API_DEFAULT */
+
+ stk->auto_op.func1 = stk->auto_op.func1_default = (H5E_auto1_t)H5Eprint1;
+ stk->auto_op.func2 = stk->auto_op.func2_default = (H5E_auto2_t)H5Eprint2;
+ stk->auto_op.is_default = TRUE;
+#else /* H5_NO_DEPRECATED_SYMBOLS */
+ stk->auto_op.func2 = (H5E_auto2_t)H5Eprint2;
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
stk->auto_data = NULL;
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -1555,6 +1563,11 @@ done:
* Programmer: Robb Matzke
* Saturday, February 28, 1998
*
+ * Modification:Raymond Lu
+ * 4 October 2010
+ * If the printing function isn't the default H5Eprint1 or 2,
+ * and H5Eset_auto1 has been called to set the old style
+ * printing function, a call to H5Eget_auto2 should fail.
*-------------------------------------------------------------------------
*/
herr_t
@@ -1578,8 +1591,15 @@ H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data)
/* Get the automatic error reporting information */
if(H5E_get_auto(estack, &op, client_data) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info")
+
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+ /* Fail if the printing function isn't the default(user-set) and set through H5Eset_auto1 */
+ if(!op.is_default && op.vers == 1)
+ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "wrong API function, H5Eset_auto1 has been called")
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
if(func)
- *func = op.u.func2;
+ *func = op.func2;
done:
FUNC_LEAVE_API(ret_value)
@@ -1606,6 +1626,9 @@ done:
* Programmer: Robb Matzke
* Friday, February 27, 1998
*
+ * Modification:Raymond Lu
+ * 4 October 2010
+ * If the FUNC is H5Eprint2, put the IS_DEFAULT flag on.
*-------------------------------------------------------------------------
*/
herr_t
@@ -1627,9 +1650,23 @@ H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data)
if(NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID")
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+ /* Get the automatic error reporting information */
+ if(H5E_get_auto(estack, &op, NULL) < 0)
+ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info")
+
/* Set the automatic error reporting information */
+ if(func != op.func2_default)
+ op.is_default = FALSE;
+ else
+ op.is_default = TRUE;
+
op.vers = 2;
- op.u.func2 = func;
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
+ /* Set the automatic error reporting function */
+ op.func2 = func;
+
if(H5E_set_auto(estack, &op, client_data) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info")
@@ -1672,7 +1709,11 @@ H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack)
/* Check if the error stack reporting function is the "newer" stack type */
if(is_stack)
+#ifndef H5_NO_DEPRECATED_SYMBOLS
*is_stack = estack->auto_op.vers > 1;
+#else
+ *is_stack = 1;
+#endif
done:
FUNC_LEAVE_API(ret_value)
diff --git a/src/H5Edeprec.c b/src/H5Edeprec.c
index 30f3ae9..0a028d9 100644
--- a/src/H5Edeprec.c
+++ b/src/H5Edeprec.c
@@ -370,6 +370,11 @@ done:
* Programmer: Raymond Lu
* Sep 16, 2003
*
+ * Modification:Raymond Lu
+ * 4 October 2010
+ * If the printing function isn't the default H5Eprint1 or 2,
+ * and H5Eset_auto2 has been called to set the new style
+ * printing function, a call to H5Eget_auto1 should fail.
*-------------------------------------------------------------------------
*/
herr_t
@@ -389,8 +394,13 @@ H5Eget_auto1(H5E_auto1_t *func, void **client_data)
/* Get the automatic error reporting information */
if(H5E_get_auto(estack, &auto_op, client_data) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info")
+
+ /* Fail if the printing function isn't the default(user-set) and set through H5Eset_auto2 */
+ if(!auto_op.is_default && auto_op.vers == 2)
+ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "wrong API function, H5Eset_auto2 has been called")
+
if(func)
- *func = auto_op.u.func1;
+ *func = auto_op.func1;
done:
FUNC_LEAVE_API(ret_value)
@@ -418,6 +428,9 @@ done:
* Programmer: Raymond Lu
* Sep 16, 2003
*
+ * Modification:Raymond Lu
+ * 4 October 2010
+ * If the FUNC is H5Eprint2, put the IS_DEFAULT flag on.
*-------------------------------------------------------------------------
*/
herr_t
@@ -434,9 +447,18 @@ H5Eset_auto1(H5E_auto1_t func, void *client_data)
if(NULL == (estack = H5E_get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack")
+ /* Get the automatic error reporting information */
+ if(H5E_get_auto(estack, &auto_op, NULL) < 0)
+ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info")
+
/* Set the automatic error reporting information */
auto_op.vers = 1;
- auto_op.u.func1 = func;
+ if(func != auto_op.func1_default)
+ auto_op.is_default = FALSE;
+ else
+ auto_op.is_default = TRUE;
+ auto_op.func1 = func;
+
if(H5E_set_auto(estack, &auto_op, client_data) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info")
diff --git a/src/H5Eint.c b/src/H5Eint.c
index 584ba40..f650581 100644
--- a/src/H5Eint.c
+++ b/src/H5Eint.c
@@ -1011,18 +1011,20 @@ H5E_dump_api_stack(hbool_t is_api)
H5E_t *estack = H5E_get_my_stack();
HDassert(estack);
+
+#ifdef H5_NO_DEPRECATED_SYMBOLS
+ if(estack->auto_op.func2)
+ (void)((estack->auto_op.func2)(H5E_DEFAULT, estack->auto_data));
+#else /* H5_NO_DEPRECATED_SYMBOLS */
if(estack->auto_op.vers == 1) {
-#ifndef H5_NO_DEPRECATED_SYMBOLS
- if(estack->auto_op.u.func1)
- (void)((estack->auto_op.u.func1)(estack->auto_data));
-#else /* H5_NO_DEPRECATED_SYMBOLS */
- HDassert(0 && "version 1 error stack dump without deprecated symbols!");
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
+ if(estack->auto_op.func1)
+ (void)((estack->auto_op.func1)(estack->auto_data));
} /* end if */
else {
- if(estack->auto_op.u.func2)
- (void)((estack->auto_op.u.func2)(H5E_DEFAULT, estack->auto_data));
+ if(estack->auto_op.func2)
+ (void)((estack->auto_op.func2)(H5E_DEFAULT, estack->auto_data));
} /* end else */
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
} /* end if */
done:
diff --git a/src/H5Epkg.h b/src/H5Epkg.h
index a85ddc9..9a1163a 100644
--- a/src/H5Epkg.h
+++ b/src/H5Epkg.h
@@ -68,15 +68,20 @@
/****************************/
/* Some syntactic sugar to make the compiler happy with two different kinds of callbacks */
-typedef struct {
- unsigned vers; /* Which version callback to use */
- union {
#ifndef H5_NO_DEPRECATED_SYMBOLS
- H5E_auto1_t func1; /* Old-style callback, NO error stack param. */
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
- H5E_auto2_t func2; /* New-style callback, with error stack param. */
- }u;
+typedef struct {
+ unsigned vers; /* Which version callback to use */
+ hbool_t is_default; /* If the printing function is the library's own. */
+ H5E_auto1_t func1; /* Old-style callback, NO error stack param. */
+ H5E_auto2_t func2; /* New-style callback, with error stack param. */
+ H5E_auto1_t func1_default; /* The saved library's default function - old style. */
+ H5E_auto2_t func2_default; /* The saved library's default function - new style. */
+} H5E_auto_op_t;
+#else /* H5_NO_DEPRECATED_SYMBOLS */
+typedef struct {
+ H5E_auto_t func2; /* Only the new style callback function is available. */
} H5E_auto_op_t;
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
/* Some syntactic sugar to make the compiler happy with two different kinds of callbacks */
typedef struct {