Searched hist:"7 eb138a9e53636366e615bdf04062fedc044bcea" (Results 1 – 3 of 3) sorted by relevance
/freebsd/lib/libc/locale/ |
H A D | localeconv.c | diff 7eb138a9e53636366e615bdf04062fedc044bcea Fri Sep 17 16:44:23 CEST 2021 Mark Johnston <markj@FreeBSD.org> libc/locale: Fix races between localeconv(3) and setlocale(3)
Each locale embeds a lazily initialized lconv which is populated by localeconv(3) and localeconv_l(3). When setlocale(3) updates the global locale, the lconv needs to be (lazily) reinitialized. To signal this, we set flag variables in the locale structure. There are two problems:
- The flags are set before the locale is fully updated, so a concurrent localeconv() call can observe partially initialized locale data. - No barriers ensure that localeconv() observes a fully initialized locale if a flag is set.
So, move the flag update appropriately, and use acq/rel barriers to provide some synchronization. Note that this is inadequate in the face of multiple concurrent calls to setlocale(3), but this is not expected to work regardless.
Thanks to Henry Hu <henry.hu.sh@gmail.com> for providing a test case demonstrating the race.
PR: 258360 MFC after: 3 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31899
|
H A D | lnumeric.c | diff 7eb138a9e53636366e615bdf04062fedc044bcea Fri Sep 17 16:44:23 CEST 2021 Mark Johnston <markj@FreeBSD.org> libc/locale: Fix races between localeconv(3) and setlocale(3)
Each locale embeds a lazily initialized lconv which is populated by localeconv(3) and localeconv_l(3). When setlocale(3) updates the global locale, the lconv needs to be (lazily) reinitialized. To signal this, we set flag variables in the locale structure. There are two problems:
- The flags are set before the locale is fully updated, so a concurrent localeconv() call can observe partially initialized locale data. - No barriers ensure that localeconv() observes a fully initialized locale if a flag is set.
So, move the flag update appropriately, and use acq/rel barriers to provide some synchronization. Note that this is inadequate in the face of multiple concurrent calls to setlocale(3), but this is not expected to work regardless.
Thanks to Henry Hu <henry.hu.sh@gmail.com> for providing a test case demonstrating the race.
PR: 258360 MFC after: 3 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31899
|
H A D | lmonetary.c | diff 7eb138a9e53636366e615bdf04062fedc044bcea Fri Sep 17 16:44:23 CEST 2021 Mark Johnston <markj@FreeBSD.org> libc/locale: Fix races between localeconv(3) and setlocale(3)
Each locale embeds a lazily initialized lconv which is populated by localeconv(3) and localeconv_l(3). When setlocale(3) updates the global locale, the lconv needs to be (lazily) reinitialized. To signal this, we set flag variables in the locale structure. There are two problems:
- The flags are set before the locale is fully updated, so a concurrent localeconv() call can observe partially initialized locale data. - No barriers ensure that localeconv() observes a fully initialized locale if a flag is set.
So, move the flag update appropriately, and use acq/rel barriers to provide some synchronization. Note that this is inadequate in the face of multiple concurrent calls to setlocale(3), but this is not expected to work regardless.
Thanks to Henry Hu <henry.hu.sh@gmail.com> for providing a test case demonstrating the race.
PR: 258360 MFC after: 3 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31899
|