From af147debc67487491ab5fd5c816ab2407d9d8eb5 Mon Sep 17 00:00:00 2001 From: Stephen Miller <56742918+StevenMiller123@users.noreply.github.com> Date: Wed, 1 Oct 2025 14:27:12 -0500 Subject: [PATCH] Lock linker mutex in RelocateAnyImports (#3693) Module relocation is not thread safe, games calling LoadAndStartModule on multiple threads can invalidate pointers while iterating through m_modules. This fixes crashes in some apps on Windows. --- src/core/linker.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/linker.h b/src/core/linker.h index fef005605..8ffcd9d45 100644 --- a/src/core/linker.h +++ b/src/core/linker.h @@ -111,6 +111,8 @@ public: } void RelocateAnyImports(Module* m) { + std::scoped_lock lk{mutex}; + Relocate(m); const auto exports = m->GetExportModules(); for (auto& export_mod : exports) {