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 | |
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')
-rw-r--r-- | lib/libthr/thread/thr_clean.c | 9 | ||||
-rw-r--r-- | lib/libthr/thread/thr_exit.c | 21 |
2 files changed, 17 insertions, 13 deletions
diff --git a/lib/libthr/thread/thr_clean.c b/lib/libthr/thread/thr_clean.c index b37a1b5..71bd94a 100644 --- a/lib/libthr/thread/thr_clean.c +++ b/lib/libthr/thread/thr_clean.c @@ -78,12 +78,10 @@ __pthread_cleanup_pop_imp(int execute) void _pthread_cleanup_push(void (*routine) (void *), void *arg) { -#ifdef _PTHREAD_FORCED_UNWIND - PANIC("_pthread_cleanup_push is not supported while stack unwinding is enabled."); -#else struct pthread *curthread = _get_curthread(); struct pthread_cleanup *newbuf; + curthread->unwind_disabled = 1; if ((newbuf = (struct pthread_cleanup *) malloc(sizeof(struct _pthread_cleanup_info))) != NULL) { newbuf->routine = routine; @@ -92,15 +90,10 @@ _pthread_cleanup_push(void (*routine) (void *), void *arg) newbuf->prev = curthread->cleanup; curthread->cleanup = newbuf; } -#endif } void _pthread_cleanup_pop(int execute) { -#ifdef _PTHREAD_FORCED_UNWIND - PANIC("_pthread_cleanup_pop is not supported while stack unwinding is enabled."); -#else __pthread_cleanup_pop_imp(execute); -#endif } 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); } |