From 56d35bf409d54bc82cdf92aa7f1be88b27899d2a Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sun, 25 Aug 2024 20:51:58 +0300 Subject: [PATCH] Fix crash in JIT when compiling LLVM blocks --- Utilities/JITASM.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Utilities/JITASM.cpp b/Utilities/JITASM.cpp index aebfbcd272..b1d227fc15 100644 --- a/Utilities/JITASM.cpp +++ b/Utilities/JITASM.cpp @@ -185,8 +185,13 @@ static u8* add_jit_memory(usz size, usz align) if (olda != newa) [[unlikely]] { #ifndef CAN_OVERCOMMIT - // Commit more memory - utils::memory_commit(pointer + olda, newa - olda, Prot); + // Commit more memory. + // NOTE: Calling memory commit in parallel on the same addresses can throw a permission error. + { + static std::mutex mcommit_lock; + std::lock_guard lock(mcommit_lock); + utils::memory_commit(pointer + olda, newa - olda, Prot); + } #endif // Acknowledge committed memory Ctr.atomic_op([&](u64& ctr)