From 087d97a0a8349e5ddb23c7476b464a0eac85409a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 9 Nov 2006 08:11:33 +0000 Subject: backport from upstream: 2001-04-10 Ulrich Drepper * join.c (pthread_exit): Move code to new function __pthread_do_exit which takes an extra parameter with the current frame pointer. Call new function with CURRENT_STACK_FRAME. (__pthread_do_exit): New function. Call __pthread_perform_cleanup with the new parameter. (pthread_join): Call __pthread_do_exit instead of pthread_exit. * cancel.c (__pthread_perform_cleanup): Takes extra parameter. Use this parameter as the initial value the cleanup handler records are compared against. No active cleanup handler record must have an address lower than the previous one and the initial record must be above (below on PA) the frame address passed in. (pthread_setcancelstate): Call __pthread_do_exit instead of pthread_exit. (pthread_setcanceltype): Likewise. (pthread_testcancel): Likewise. (_pthread_cleanup_pop_restore): Likewise. * condvar.c (pthread_cond_wait): Likewise. (pthread_cond_timedwait_relative): Likewise. * manager.c (pthread_start_thread): Likewise. * oldsemaphore.c (__old_sem_wait): Likewise. * pthread.c (pthread_handle_sigcancel): Likewise. * semaphore.c (__new_sem_wait): Likewise. (sem_timedwait): Likewise. * ptlongjmp.c (pthread_cleanup_upto): Also use current stack frame to limit the cleanup handlers which get run. * internals.h: Add prototype for __pthread_do_exit. Adjust prototype for __pthread_perform_cleanup. --- libpthread/linuxthreads.old/ptlongjmp.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'libpthread/linuxthreads.old/ptlongjmp.c') diff --git a/libpthread/linuxthreads.old/ptlongjmp.c b/libpthread/linuxthreads.old/ptlongjmp.c index 055a217d3..b3ff2746f 100644 --- a/libpthread/linuxthreads.old/ptlongjmp.c +++ b/libpthread/linuxthreads.old/ptlongjmp.c @@ -18,6 +18,7 @@ #include #include "pthread.h" #include "internals.h" +#include /* These functions are not declared anywhere since they shouldn't be used at another place but here. */ @@ -28,11 +29,29 @@ static void pthread_cleanup_upto(__jmp_buf target) { pthread_descr self = thread_self(); struct _pthread_cleanup_buffer * c; + char *currentframe = CURRENT_STACK_FRAME; for (c = THREAD_GETMEM(self, p_cleanup); c != NULL && _JMPBUF_UNWINDS(target, c); c = c->__prev) - c->__routine(c->__arg); + { +#if _STACK_GROWS_DOWN + if ((char *) c <= currentframe) + { + c = NULL; + break; + } +#elif _STACK_GROWS_UP + if ((char *) c >= currentframe) + { + c = NULL; + break; + } +#else +# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP" +#endif + c->__routine(c->__arg); + } THREAD_SETMEM(self, p_cleanup, c); if (THREAD_GETMEM(self, p_in_sighandler) && _JMPBUF_UNWINDS(target, THREAD_GETMEM(self, p_in_sighandler))) -- cgit v1.2.3