- Created 2007-Aug-28 07:13:21 by anonymous
-
Changed description.
*** 2,4 ****
The following patch returns the static exception context as __ex_ctx_default() does in the case pthread_getspecific() returns NULL. It also uses the default termination function in pthread_ex_terminate in this case.
-
*** pthread_ex.c.orig 2007-08-28 06:50:53.000000000 +0200
--- 2,3 ----
by anonymous on 2007-Aug-28 07:17
-
Changed description.
*** 2,3 ****
--- 2,4 ----
The following patch returns the static exception context as __ex_ctx_default() does in the case pthread_getspecific() returns NULL. It also uses the default termination function in pthread_ex_terminate in this case.
+
*** pthread_ex.c.orig 2007-08-28 06:50:53.000000000 +0200
by anonymous on 2007-Aug-28 07:18
- Attachment
patch
919 bytes added by anonymous on 2007-Aug-28 07:19:08.
-
Changed description.
*** 1,42 ****
If the pthread module from the man page is used, pthread_init() sets the function to retrieve the exception context (__ex_ctx) to pthread_ex_ctx(). This function only results with a pointer to an exception context struct when there was that data assiciated to the thread before with pthread_setspecific() which is always done when a thread is created with the create wrapper. But for the main program thread pthread_getspecific returns NULL resulting in a segmantation fault when NULL is referenced later on (this usually occurs in the ex_try macro when accessing the machine context).
! The following patch returns the static exception context as __ex_ctx_default() does in the case pthread_getspecific() returns NULL. It also uses the default termination function in pthread_ex_terminate in this case.
!
! *** pthread_ex.c.orig 2007-08-28 06:50:53.000000000 +0200
! --- pthread_ex.c 2007-08-28 06:49:02.000000000 +0200
! ***************
! *** 20,32 ****
! /* callback: context fetching */
! static ex_ctx_t *pthread_ex_ctx(void)
! {
! ! return (ex_ctx_t *)
! ! pthread_getspecific(pthread_ex_ctx_key);
! }
!
! /* callback: termination */
! static void pthread_ex_terminate(ex_t *e)
! {
! pthread_exit(e->ex_value);
! }
!
! --- 20,41 ----
! /* callback: context fetching */
! static ex_ctx_t *pthread_ex_ctx(void)
! {
! ! ex_ctx_t* ctx = (ex_ctx_t *)pthread_getspecific(pthread_ex_ctx_key);
! !
! ! if (!ctx)
! ! return __ex_ctx_default();
! !
! ! return ctx;
! }
!
! /* callback: termination */
! static void pthread_ex_terminate(ex_t *e)
! {
! + ex_ctx_t* ctx = (ex_ctx_t *)pthread_getspecific(pthread_ex_ctx_key);
! +
! + if (!ctx)
! + __ex_terminate_default(e);
! +
! pthread_exit(e->ex_value);
! }
--- 1,2 ----
If the pthread module from the man page is used, pthread_init() sets the function to retrieve the exception context (__ex_ctx) to pthread_ex_ctx(). This function only results with a pointer to an exception context struct when there was that data assiciated to the thread before with pthread_setspecific() which is always done when a thread is created with the create wrapper. But for the main program thread pthread_getspecific returns NULL resulting in a segmantation fault when NULL is referenced later on (this usually occurs in the ex_try macro when accessing the machine context).
! The attached patch returns the static exception context as __ex_ctx_default() does in the case pthread_getspecific() returns NULL. It also uses the default termination function in pthread_ex_terminate in this case.
by anonymous on 2007-Aug-28 07:19
- Check-in
[5973]: Fix example given under "MULTITHREADING ENVIRONMENTS" in the manual page. The problem is that the context can be still not associated and hence be NULL. Submitted by: Frank Hempel <red_socks@gmx.de>(By rse on 2007-Oct-12 21:57)
-
Change status from "new" to "fixed"
by rse on 2007-Oct-12 21:58