ICU-20689 Fix race condition in UMutex code, leading to random crashes.

This commit is contained in:
Jeff Genovy 2019-07-03 14:04:36 -07:00
parent d56f291178
commit 2cd213ac3b

View File

@ -90,7 +90,8 @@ std::mutex *UMutex::getMutex() {
if (retPtr == nullptr) {
std::call_once(*pInitFlag, umtx_init);
std::lock_guard<std::mutex> 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;