未验证 提交 ee2b1327 编写于 作者: O openharmony_ci 提交者: Gitee

!883 feat:修复pthread_exit中设置线程detach_state状态的位置

Merge pull request !883 from zhangdengyu/fixPthread0426
......@@ -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.
先完成此消息的编辑!
想要评论请 注册