From 7bb717f355e97b8668bca3c09288cd3e639c4eb5 Mon Sep 17 00:00:00 2001 From: minerjr Date: Wed, 23 Apr 2025 10:52:38 -0300 Subject: [PATCH] [FIRE-35382] - Add share_mutex to fix JointKey::construct lockup Added a share_mutex to the JointKey::construct to fix the lockup when the unordered_map gets corrupted. Set the shared_lock when reading and unique_lock when writing to. --- indra/llcharacter/lljoint.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index 91f33a73eb..f619fe132b 100644 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -34,21 +34,29 @@ #include "llmath.h" #include +#include "llmutex.h" // [FIRE-35382] Add share_mutex to fix JointKey::construct lockup // Query by JointKey rather than just a string, the key can be a U32 index for faster lookup #include std::unordered_map mpStringToKeys; +std::shared_mutex mpStringToKeysMutex; // [FIRE-35382] Add share_mutex to fix JointKey::construct lockup JointKey JointKey::construct(const std::string& aName) { + {// [FIRE-35382] Add share_mutex to fix JointKey::construct lockup + std::shared_lock lock(mpStringToKeysMutex); // [FIRE-35382] Added a shared lock for reading the mpStringToKeys unordered_map. if (const auto itr = mpStringToKeys.find(aName); itr != mpStringToKeys.end()) { return { aName, itr->second }; } + }// [FIRE-35382] Add share_mutex to fix JointKey::construct lockup + { // Add a unique lock for writing to the mpStringToKeys unordered_map. + std::unique_lock lock(mpStringToKeysMutex);// [FIRE-35382] U32 size = static_cast(mpStringToKeys.size()) + 1; mpStringToKeys.try_emplace(aName, size); return { aName, size }; + } // [FIRE-35382] Add share_mutex to fix JointKey::construct lockup } //