mirror of https://github.com/RPCS3/rpcs3
Fixup futex emulation
std::unordered_multimap::find may return any matching element.. unlike equal_range. (code relied on matching the first) There was also UB there of reference to an element after it has deleted.
This commit is contained in:
parent
de8552048f
commit
103d580d9a
|
|
@ -81,9 +81,9 @@ inline int futex(volatile void* uaddr, int futex_op, uint val, const timespec* t
|
|||
{
|
||||
struct waiter
|
||||
{
|
||||
uint val;
|
||||
uint mask;
|
||||
std::condition_variable cv;
|
||||
uint val;
|
||||
uint mask;
|
||||
std::condition_variable cv;
|
||||
};
|
||||
|
||||
std::mutex mutex;
|
||||
|
|
@ -111,7 +111,7 @@ inline int futex(volatile void* uaddr, int futex_op, uint val, const timespec* t
|
|||
waiter rec;
|
||||
rec.val = val;
|
||||
rec.mask = mask;
|
||||
const auto& ref = *map.emplace(uaddr, &rec);
|
||||
const auto itr = map.emplace(uaddr, &rec);
|
||||
|
||||
int res = 0;
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ inline int futex(volatile void* uaddr, int futex_op, uint val, const timespec* t
|
|||
// TODO: absolute timeout
|
||||
}
|
||||
|
||||
map.erase(std::find(map.find(uaddr), map.end(), ref));
|
||||
map.erase(itr);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2228,11 +2228,8 @@ void lv2_obj::notify_all() noexcept
|
|||
break;
|
||||
}
|
||||
|
||||
if (cpu != &g_to_notify)
|
||||
{
|
||||
// Note: by the time of notification the thread could have been deallocated which is why the direct function is used
|
||||
atomic_wait_engine::notify_all(cpu);
|
||||
}
|
||||
// Note: by the time of notification the thread could have been deallocated which is why the direct function is used
|
||||
atomic_wait_engine::notify_all(cpu);
|
||||
}
|
||||
|
||||
g_to_notify[0] = nullptr;
|
||||
|
|
|
|||
Loading…
Reference in New Issue