Fix sys_spu_thread_group_join wait condition

After waiting, thread group cannot be safely accessed
Following #5643
This commit is contained in:
Nekotekina 2019-02-10 18:22:48 +03:00
parent 9ee2867247
commit f143035af1
2 changed files with 3 additions and 3 deletions

View File

@ -531,6 +531,7 @@ void spu_thread::cpu_stop()
// Send exit status directly to the joining thread
ppu->gpr[4] = group->join_state;
ppu->gpr[5] = group->exit_status;
group->join_state.release(0);
}
}

View File

@ -659,12 +659,13 @@ error_code sys_spu_thread_group_join(ppu_thread& ppu, u32 id, vm::ptr<u32> cause
else
{
// Subscribe to receive status in r4-r5
ppu.gpr[4] = 0;
group->waiter = &ppu;
}
lv2_obj::sleep(ppu);
while (!group->join_state || group->run_state != SPU_THREAD_GROUP_STATUS_INITIALIZED)
while (!ppu.gpr[4])
{
if (ppu.is_stopped())
{
@ -673,8 +674,6 @@ error_code sys_spu_thread_group_join(ppu_thread& ppu, u32 id, vm::ptr<u32> cause
group->cond.wait(lock);
}
group->join_state.release(0);
}
while (0);