summaryrefslogtreecommitdiff
path: root/Source/Android
diff options
context:
space:
mode:
authormitaclaw <140017135+mitaclaw@users.noreply.github.com>2024-07-28 15:45:52 -0700
committermitaclaw <140017135+mitaclaw@users.noreply.github.com>2024-07-28 16:10:59 -0700
commit4f0954dd447ca604832688f6eb9798e8245ca334 (patch)
treea9e01b47a20395ffa0dfc96273caa20f54e8c884 /Source/Android
parent53d2311163ae3deee54f6088d3dc257e495b4bf5 (diff)
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.
Diffstat (limited to 'Source/Android')
-rw-r--r--Source/Android/jni/MainAndroid.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp
index 2ca05572a8..811b28c32b 100644
--- a/Source/Android/jni/MainAndroid.cpp
+++ b/Source/Android/jni/MainAndroid.cpp
@@ -417,6 +417,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteJitBloc
HostThreadLock guard;
auto& system = Core::System::GetInstance();
auto& jit_interface = system.GetJitInterface();
+ const Core::CPUThreadGuard cpu_guard(system);
if (jit_interface.GetCore() == nullptr)
{
env->CallStaticVoidMethod(native_library_class, IDCache::GetDisplayToastMsg(),
@@ -434,7 +435,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteJitBloc
JNI_FALSE);
return;
}
- jit_interface.JitBlockLogDump(Core::CPUThreadGuard{system}, f.GetHandle());
+ jit_interface.JitBlockLogDump(cpu_guard, f.GetHandle());
env->CallStaticVoidMethod(native_library_class, IDCache::GetDisplayToastMsg(),
ToJString(env, Common::FmtFormatT("Wrote to \"{0}\".", filename)),
JNI_FALSE);