android: race condition on Emulator::threadResult
The emu thread can be stopped/started by the app main java thread while the render thread is running. This can lead to a race condition on the threadResult future between checkStatus() and start(). So protect relevant sections with a mutex. Fix for MINIDUMP-1G, MINIDUMP-1H, MINIDUMP-2G and MINIDUMP-33
This commit is contained in:
parent
2da833883b
commit
659d21680b
|
@ -847,6 +847,7 @@ void Emulator::start()
|
|||
|
||||
if (config::ThreadedRendering)
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
threadResult = std::async(std::launch::async, [this] {
|
||||
InitAudio();
|
||||
|
||||
|
@ -881,6 +882,7 @@ void Emulator::start()
|
|||
bool Emulator::checkStatus()
|
||||
{
|
||||
try {
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
if (threadResult.valid())
|
||||
{
|
||||
auto result = threadResult.wait_for(std::chrono::seconds(0));
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <string>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <mutex>
|
||||
|
||||
void loadGameSpecificSettings();
|
||||
void SaveSettings();
|
||||
|
@ -178,6 +179,7 @@ private:
|
|||
u32 stepRangeFrom = 0;
|
||||
u32 stepRangeTo = 0;
|
||||
bool stopRequested = false;
|
||||
std::mutex mutex;
|
||||
};
|
||||
extern Emulator emu;
|
||||
|
||||
|
|
Loading…
Reference in New Issue