Page MenuHomeFreeBSD

locale: persistent mbstates should be reset when rune locale changes
ClosedPublic

Authored by yuripv on Nov 1 2018, 9:30 AM.
Tags
None
Referenced Files
F173000171: D17796.id50189.diff
Tue, Sep 22, 6:43 PM
F172999487: D17796.id49866.diff
Tue, Sep 22, 6:35 PM
F172986318: D17796.diff
Tue, Sep 22, 4:03 PM
Unknown Object (File)
Tue, Sep 22, 1:17 AM
Unknown Object (File)
Sun, Sep 20, 12:57 PM
Unknown Object (File)
Sun, Sep 13, 5:30 AM
Unknown Object (File)
Sat, Sep 5, 12:41 AM
Unknown Object (File)
Sat, Aug 29, 8:06 AM
Subscribers

Details

Summary

The test marked as expected to fail in /usr/tests/lib/libc/locale/mbrtowctest (https://github.com/freebsd/freebsd/blob/7bddbea75ccbb4c0d4a2ca5b0e8ce713a878b016/contrib/netbsd-tests/lib/libc/locale/t_mbrtowc.c#L242) seems to be showing a real issue -- when changing ctype component of locale, we can have a state that is perfectly normal for previous locale encoding, and is invalid for new one, leading to unexpected conversion failure. More so, when the locale encoding changes, the meaning of data in opaque structure __mbstate changes as well (every encoding seems to have its own structure). All this lead me to this change resetting the persistent mbstates when new rune locale data is loaded, which required moving the fields from struct _xlocale to its ctype component.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable