summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2010-09-21 16:46:38 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2010-09-21 16:46:38 (GMT)
commitd6c6a34a8f5876d21dee052c74426b0606b62d13 (patch)
tree67b0dddc97926eae54a6fd23a563a4e2296dabab /src
parentba71366f9867bd2d817abf6715a5445237023c6f (diff)
downloadhdf5-d6c6a34a8f5876d21dee052c74426b0606b62d13.zip
hdf5-d6c6a34a8f5876d21dee052c74426b0606b62d13.tar.gz
hdf5-d6c6a34a8f5876d21dee052c74426b0606b62d13.tar.bz2
[svn-r19457] 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 union in the structure H5E_auto_t. Another change is to make H5Eget_auto fail if H5Eset_auto is called to set the printing function. I'll write a document for it. 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/H5.c9
-rw-r--r--src/H5E.c25
-rw-r--r--src/H5Edeprec.c9
-rw-r--r--src/H5Eint.c8
-rw-r--r--src/H5Epkg.h11
5 files changed, 39 insertions, 23 deletions
diff --git a/src/H5.c b/src/H5.c
index 0a14c6e..97c4036 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -214,7 +214,7 @@ H5_term_library(void)
int pending, ntries = 0, n;
size_t at = 0;
char loop[1024];
- H5E_auto2_t func;
+ H5E_auto_t func;
#ifdef H5_HAVE_THREADSAFE
/* explicit locking of the API */
@@ -227,8 +227,11 @@ H5_term_library(void)
goto done;
/* Check if we should display error output */
- (void)H5Eget_auto2(H5E_DEFAULT, &func, NULL);
-
+#ifdef H5_USE_16_API_DEFAULT
+ (void)H5Eget_auto(&func, NULL);
+#else
+ (void)H5Eget_auto(H5E_DEFAULT, &func, NULL);
+#endif
/*
* Terminate each interface. The termination functions return a positive
* value if they do something that might affect some other interface in a
diff --git a/src/H5E.c b/src/H5E.c
index 01dd35b..55137ba 100644
--- a/src/H5E.c
+++ b/src/H5E.c
@@ -170,13 +170,19 @@ H5E_set_default_auto(H5E_t *stk)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_set_default_auto)
-#ifdef H5_USE_16_API
+#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 */
+#else /* H5_USE_16_API_DEFAULT */
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 */
+#ifdef H5_NO_DEPRECATED_SYMBOLS
+ stk->auto_op.vers = 2;
+ stk->auto_op.func1 = NULL;
+#else
+ stk->auto_op.func1 = (H5E_auto1_t)H5Eprint1;
+#endif
+ stk->auto_op.func2 = (H5E_auto2_t)H5Eprint2;
+ stk->auto_op.user_set = FALSE;
stk->auto_data = NULL;
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -1578,8 +1584,12 @@ 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")
+
+ if(op.user_set && op.vers == 1)
+ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "wrong API function, H5Eset_auto1 has been called")
+
if(func)
- *func = op.u.func2;
+ *func = op.func2;
done:
FUNC_LEAVE_API(ret_value)
@@ -1629,7 +1639,8 @@ H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data)
/* Set the automatic error reporting information */
op.vers = 2;
- op.u.func2 = func;
+ op.user_set = TRUE;
+ 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")
diff --git a/src/H5Edeprec.c b/src/H5Edeprec.c
index 30f3ae9..9f6d869 100644
--- a/src/H5Edeprec.c
+++ b/src/H5Edeprec.c
@@ -389,8 +389,12 @@ 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")
+
+ if(auto_op.user_set && 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)
@@ -436,7 +440,8 @@ H5Eset_auto1(H5E_auto1_t func, void *client_data)
/* Set the automatic error reporting information */
auto_op.vers = 1;
- auto_op.u.func1 = func;
+ auto_op.user_set = 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..75aadda 100644
--- a/src/H5Eint.c
+++ b/src/H5Eint.c
@@ -1013,15 +1013,15 @@ H5E_dump_api_stack(hbool_t is_api)
HDassert(estack);
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));
+ if(estack->auto_op.func1)
+ (void)((estack->auto_op.func1)(estack->auto_data));
#else /* H5_NO_DEPRECATED_SYMBOLS */
HDassert(0 && "version 1 error stack dump without deprecated symbols!");
#endif /* H5_NO_DEPRECATED_SYMBOLS */
} /* 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 */
} /* end if */
diff --git a/src/H5Epkg.h b/src/H5Epkg.h
index a85ddc9..fc82502 100644
--- a/src/H5Epkg.h
+++ b/src/H5Epkg.h
@@ -69,13 +69,10 @@
/* 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;
+ unsigned vers; /* Which version callback to use */
+ hbool_t user_set;
+ H5E_auto1_t func1; /* Old-style callback, NO error stack param. */
+ H5E_auto2_t func2; /* New-style callback, with error stack param. */
} H5E_auto_op_t;
/* Some syntactic sugar to make the compiler happy with two different kinds of callbacks */