diff options
author | davidxu <davidxu@FreeBSD.org> | 2010-09-25 06:27:09 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2010-09-25 06:27:09 +0000 |
commit | 121f2e2d6046b2925addd629e988e5e22cbb4913 (patch) | |
tree | f35b7657d512b1644b5f02154557d5cd675bd8e8 /lib/libthr/thread/thr_exit.c | |
parent | 6f2607a695bd1cec08544ece0ef78894b503df3d (diff) | |
download | FreeBSD-src-121f2e2d6046b2925addd629e988e5e22cbb4913.zip FreeBSD-src-121f2e2d6046b2925addd629e988e5e22cbb4913.tar.gz |
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.
Diffstat (limited to 'lib/libthr/thread/thr_exit.c')
-rw-r--r-- | lib/libthr/thread/thr_exit.c | 21 |
1 files changed, 16 insertions, 5 deletions
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); } |