Core: Fix thread unsafety issue when dispatching code to a thread
Vicki Pfau vi@endrift.com
Sat, 14 Nov 2020 16:42:51 -0800
2 files changed,
4 insertions(+),
0 deletions(-)
M
CHANGES
→
CHANGES
@@ -49,6 +49,7 @@ - All: Improve export headers (fixes mgba.io/i/1738)
- CMake: Fix build with downstream minizip that exports incompatible symbols - Core: Ensure ELF regions can be written before trying - Core: Fix threading improperly setting paused state while interrupted + - Core: Fix thread unsafety issue when dispatching code to a thread - Debugger: Don't skip undefined instructions when debugger attached - Debugger: Close trace log when done tracing - FFmpeg: Fix some small memory leaks
M
src/core/thread.c
→
src/core/thread.c
@@ -267,7 +267,10 @@ case THREAD_RUN_ON:
if (threadContext->run) { threadContext->run(threadContext); } + MutexLock(&threadContext->impl->stateMutex); threadContext->impl->state = threadContext->impl->savedState; + ConditionWake(&threadContext->impl->stateCond); + MutexUnlock(&threadContext->impl->stateMutex); break; case THREAD_RESETING: core->reset(core);