Description[TSAN] Fix TSAN error in i18n RTL.
Use an atomic to protect the global g_icu_text_direction cached value
from multiple readers/writers.
Also reduce acccess to g_icu_text_diretion so it only has a single write
location (in SetICUDefaultLocal) and a single read location (ICUIsRTL),
to simplify the race-y-ness.
Outside of test code, SetICUDefaultLocal is only used in two locations:
ppapi_plugin_main.cc and l10n_util.cc, whereas IsRTL is used in >100
places outside of test code, so it seemed reasonable to move the heavy
logic (updating g_icu_text_direction when it changes) into what I imagine to be
a function that is called rarely and let the one that is used a lot
(IsRTL/ICUIsRTL) just do a simple read.
This still still leaves a race condition in that IsRTL may give in
inaccurate result if SetICUDefaultLocale is executed at the same time.
In particular, IsRTL may return the value for the previously set default
locale after the default locale has been updated.
BUG=695929
TEST=cast_shell_browsertests under TSAN before/after
Review-Url: https://codereview.chromium.org/2877983004
Cr-Commit-Position: refs/heads/master@{#472890}
Committed: https://chromium.googlesource.com/chromium/src/+/89c24d4a46c1f0e7ad03891a659e6d23dc776c36
Patch Set 1 #Patch Set 2 : Be consistent casting things #Patch Set 3 : fix typo in type name #Messages
Total messages: 15 (7 generated)
|