Hide Forgot
src/hb-common.cc:hb_language_get_default() uses setlocale(), which is not thread-safe, in a context which is clearly intended as thread-safe due to the presence of atomics. The function should use a thread-safe way to obtain the necessary information instead.
I don't know of any thread-safe alternatives to setlocale().
(In reply to Behdad Esfahbod from comment #2) > I don't know of any thread-safe alternatives to setlocale(). I'm not sure what Harfbuzz is doing with the returned string. In principle, there are newlocale(), uselocale() and nl_langinfo_l() which could be used to emulate this functionality without changing global state.
(In reply to Florian Weimer from comment #3) > (In reply to Behdad Esfahbod from comment #2) > > I don't know of any thread-safe alternatives to setlocale(). > > I'm not sure what Harfbuzz is doing with the returned string. We copy it and never use it again. > In principle, > there are newlocale(), uselocale() and nl_langinfo_l() which could be used > to emulate this functionality without changing global state. All we are doing is to query the current set locale. We don't change the global state. I don't see any way to query current locale with any other function. The alternative would be to query the envvars, which means user's setlocale() will be ignored.
Basically what we are relying on is that user doesn't change locale after spawning multiple threads.
Florian, Can this be closed as NOTABUG?