提交 46818cdd 编写于 作者: Z zhangdengyu

feat: 修复pthread_exit中设置线程gdetach状态的位置

1、将设置线程detach状态的位置改为操作pthread链表之后,
   消除线程抢占之后执行pthread_join操作直接将线程从内核态删除
   并取消用户态内存映射导致用户态pthread节点未从pthread链表中删除的场景。

Close: #I6JO8B
Signed-off-by: Nzhangdengyu <zhangdengyu2@huawei.com>
Change-Id: I71d01ca0fefe4c036f174a7e63f62097865ec89d
上级 f3e9facd
......@@ -70,18 +70,6 @@ _Noreturn void __pthread_exit(void *result)
__block_app_sigs(&set);
/* This atomic potentially competes with a concurrent pthread_detach
* call; the loser is responsible for freeing thread resources. */
int state = a_cas(&self->detach_state, DT_JOINABLE, DT_EXITING);
if (state==DT_DETACHED && self->map_base) {
/* Since __unmapself bypasses the normal munmap code path,
* explicitly wait for vmlock holders first. This must be
* done before any locks are taken, to avoid lock ordering
* issues that could lead to deadlock. */
__vm_wait();
}
/* Access to target the exiting thread with syscalls that use
* its kernel tid is controlled by killlock. For detached threads,
* any use past this point would have undefined behavior, but for
......@@ -99,7 +87,6 @@ _Noreturn void __pthread_exit(void *result)
if (self->next == self) {
__tl_unlock();
UNLOCK(self->killlock);
self->detach_state = state;
__restore_sigs(&set);
exit(0);
}
......@@ -138,6 +125,10 @@ _Noreturn void __pthread_exit(void *result)
self->prev->next = self->next;
self->prev = self->next = self;
/* This atomic potentially competes with a concurrent pthread_detach
* call; the loser is responsible for freeing thread resources. */
int state = a_cas(&self->detach_state, DT_JOINABLE, DT_EXITING);
#if 0
if (state==DT_DETACHED && self->map_base) {
/* Robust list will no longer be valid, and was already
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册