MainAndroid: Thread Correctness In WriteJitBlockLogDump
In a race condition, the core could shut down between the `JitInterface::GetCore` nullptr check and the `JitInterface::JitBlockLogDump` call which constructs a `CPUThreadGuard`. In this scenario, nothing horrible happens—`JitBlockLogDump` also checks for a nullptr—but it would be a failure to display the correct feedback to the user.
This commit is contained in:
parent
53d2311163
commit
4f0954dd44
|
@ -417,6 +417,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteJitBloc
|
||||||
HostThreadLock guard;
|
HostThreadLock guard;
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = Core::System::GetInstance();
|
||||||
auto& jit_interface = system.GetJitInterface();
|
auto& jit_interface = system.GetJitInterface();
|
||||||
|
const Core::CPUThreadGuard cpu_guard(system);
|
||||||
if (jit_interface.GetCore() == nullptr)
|
if (jit_interface.GetCore() == nullptr)
|
||||||
{
|
{
|
||||||
env->CallStaticVoidMethod(native_library_class, IDCache::GetDisplayToastMsg(),
|
env->CallStaticVoidMethod(native_library_class, IDCache::GetDisplayToastMsg(),
|
||||||
|
@ -434,7 +435,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteJitBloc
|
||||||
JNI_FALSE);
|
JNI_FALSE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
jit_interface.JitBlockLogDump(Core::CPUThreadGuard{system}, f.GetHandle());
|
jit_interface.JitBlockLogDump(cpu_guard, f.GetHandle());
|
||||||
env->CallStaticVoidMethod(native_library_class, IDCache::GetDisplayToastMsg(),
|
env->CallStaticVoidMethod(native_library_class, IDCache::GetDisplayToastMsg(),
|
||||||
ToJString(env, Common::FmtFormatT("Wrote to \"{0}\".", filename)),
|
ToJString(env, Common::FmtFormatT("Wrote to \"{0}\".", filename)),
|
||||||
JNI_FALSE);
|
JNI_FALSE);
|
||||||
|
|
Loading…
Reference in New Issue