提交 1ebde9c3 编写于 作者: R Rich Felker

fix pthread_exit from cancellation handler

cancellation frames were not correctly popped, so this usage would not
only loop, but also reuse discarded and invalid parts of the stack.
上级 9080cc15
...@@ -18,12 +18,13 @@ weak_alias(dummy_1, __pthread_tsd_run_dtors); ...@@ -18,12 +18,13 @@ weak_alias(dummy_1, __pthread_tsd_run_dtors);
void __pthread_unwind_next(struct __ptcb *cb) void __pthread_unwind_next(struct __ptcb *cb)
{ {
pthread_t self; pthread_t self = pthread_self();
int n; int n;
if (cb->__next) longjmp((void *)cb->__next->__jb, 1); if (cb->__next) {
self->cancelbuf = cb->__next->__next;
self = pthread_self(); longjmp((void *)cb->__next->__jb, 1);
}
LOCK(&self->exitlock); LOCK(&self->exitlock);
...@@ -104,7 +105,6 @@ int pthread_create(pthread_t *res, const pthread_attr_t *attr, void *(*entry)(vo ...@@ -104,7 +105,6 @@ int pthread_create(pthread_t *res, const pthread_attr_t *attr, void *(*entry)(vo
new->detached = attr->_a_detach; new->detached = attr->_a_detach;
new->attr = *attr; new->attr = *attr;
new->unblock_cancel = self->cancel; new->unblock_cancel = self->cancel;
new->result = PTHREAD_CANCELED;
memcpy(new->tlsdesc, self->tlsdesc, sizeof new->tlsdesc); memcpy(new->tlsdesc, self->tlsdesc, sizeof new->tlsdesc);
new->tlsdesc[1] = (uintptr_t)new; new->tlsdesc[1] = (uintptr_t)new;
stack = (void *)((uintptr_t)new-1 & ~(uintptr_t)15); stack = (void *)((uintptr_t)new-1 & ~(uintptr_t)15);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册