From 121f2e2d6046b2925addd629e988e5e22cbb4913 Mon Sep 17 00:00:00 2001 From: davidxu Date: Sat, 25 Sep 2010 06:27:09 +0000 Subject: Because old _pthread_cleanup_push/pop do not have frame address, it is incompatible with stack unwinding code, if they are invoked, disable stack unwinding for current thread, and when thread is exiting, print a warning message. --- lib/libthr/thread/thr_exit.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'lib/libthr/thread/thr_exit.c') diff --git a/lib/libthr/thread/thr_exit.c b/lib/libthr/thread/thr_exit.c index 67026b2..4cd581e 100644 --- a/lib/libthr/thread/thr_exit.c +++ b/lib/libthr/thread/thr_exit.c @@ -51,6 +51,7 @@ static void exit_thread(void) __dead2; __weak_reference(_pthread_exit, pthread_exit); #ifdef _PTHREAD_FORCED_UNWIND +static int message_printed; static void thread_unwind(void) __dead2; #ifdef PIC @@ -220,18 +221,28 @@ _pthread_exit_mask(void *status, sigset_t *mask) /* Save the return value: */ curthread->ret = status; #ifdef _PTHREAD_FORCED_UNWIND + #ifdef PIC thread_uw_init(); +#endif /* PIC */ + +#ifdef PIC if (uwl_forcedunwind != NULL) { - thread_unwind(); - } #else if (_Unwind_ForcedUnwind != NULL) { +#endif + if (curthread->unwind_disabled) { + if (message_printed == 0) { + message_printed = 1; + _thread_printf(2, "Warning: old _pthread_cleanup_push was called, " + "stack unwinding is disabled.\n"); + } + goto cleanup; + } thread_unwind(); - } -#endif /* PIC */ - else { + } else { +cleanup: while (curthread->cleanup != NULL) { __pthread_cleanup_pop_imp(1); } -- cgit v1.1