From 2cd213ac3b5d524acfcae85f689e7b3c1df47d2c Mon Sep 17 00:00:00 2001 From: Jeff Genovy <29107334+jefgen@users.noreply.github.com> Date: Wed, 3 Jul 2019 14:04:36 -0700 Subject: [PATCH] ICU-20689 Fix race condition in UMutex code, leading to random crashes. --- icu4c/source/common/umutex.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/icu4c/source/common/umutex.cpp b/icu4c/source/common/umutex.cpp index d31753ff31..8be43bf960 100644 --- a/icu4c/source/common/umutex.cpp +++ b/icu4c/source/common/umutex.cpp @@ -90,7 +90,8 @@ std::mutex *UMutex::getMutex() { if (retPtr == nullptr) { std::call_once(*pInitFlag, umtx_init); std::lock_guard guard(*initMutex); - if (fMutex.load() == nullptr) { + retPtr = fMutex.load(std::memory_order_acquire); + if (retPtr == nullptr) { fMutex = new(fStorage) std::mutex(); retPtr = fMutex; fListLink = gListHead;