[Bug 258360] race between setlocale() and iconv_open() causes segfault

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 08 Sep 2021 13:37:32 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258360

Mark Johnston <markj@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|New                         |Open

--- Comment #2 from Mark Johnston <markj@FreeBSD.org> ---
(In reply to Xin LI from comment #1)
The basic problem is that localeconv_l() updates the global lconv lazily.  When
setlocale() updates the process-global locale, it sets a couple of flags,
monetary_locale_changed and numeric_locale_changed, to indicate that the lconv
needs to be reloaded.  But setlocale() sets those flags before it's actually
finished doing some swizzling.

Note that the problem doesn't directly involve iconv_open(), it just happens to
be triggered because iconv calls snprintf() at some point.  I'm having a hard
time understanding what guarantees we're supposed to provide here, POSIX
doesn't seem to say much about thread-safety and setlocale(), but it seems
pretty reasonable to expect localeconv_l() to behave correctly wrt a concurrent
setlocale() call, though.

-- 
You are receiving this mail because:
You are the assignee for the bug.