mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-16 15:11:52 +00:00
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.
This commit is contained in:
parent
0c236c4ebd
commit
8690b9f6dd
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=213159
@ -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
|
||||
}
|
||||
|
@ -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();
|
||||
if (uwl_forcedunwind != NULL) {
|
||||
thread_unwind();
|
||||
}
|
||||
#else
|
||||
if (_Unwind_ForcedUnwind != NULL) {
|
||||
thread_unwind();
|
||||
}
|
||||
#endif /* PIC */
|
||||
|
||||
else {
|
||||
#ifdef PIC
|
||||
if (uwl_forcedunwind != NULL) {
|
||||
#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();
|
||||
|
||||
} else {
|
||||
cleanup:
|
||||
while (curthread->cleanup != NULL) {
|
||||
__pthread_cleanup_pop_imp(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user