Date: Tue, 10 Sep 2019 20:43:12 +0200 From: Szabolcs Nagy <nsz@...t70.net> To: Daniel Schoepe <daniel@...oepe.org> Cc: musl@...ts.openwall.com Subject: Re: printf doesn't respect locale * Daniel Schoepe <daniel@...oepe.org> [2019-09-10 18:10:20 +0100]: > Basically, someone used printf to produce json output and was unaware > that the radix used by printf was locale-dependent. When this was run > on a system with a non-English locale, it no longer produced valid > JSON as output. ok, i thought using '.' unconditionally caused some problem. i've seen plenty issues with locale dependent radix point when numbers unexpectedly have ',', but the current musl behaviour exactly prevents those types of bugs and i'd prefer to keep it that way. simple scripts parsing some program output will not be tested across different locales. global state dependence is bad in general in systems software which often communicates between machines, not humans, and you cant afford to synchronize that global state or deal with its combinatorics. in particular libraries can't use any api with global state dependence if that state may change asynchronously, thread-local state is a bit better (and since posix2008 locales can be thread-local), but it still has issues e.g. dprintf is implemented to be async-signal-safe, but in a signal handler you can't change the locale setting to get reliable dprintf behaviour and it's inefficient/inconvenient to save/restore tls state around every printf call anyway. i think libc should mainly aim for reliability of systems software and not for friendliness of ui applications. > > Best, > Daniel > > On Tue, Sep 10, 2019 at 5:31 PM Szabolcs Nagy <nsz@...t70.net> wrote: > > > > * Daniel Schoepe <daniel@...oepe.org> [2019-09-10 17:00:49 +0100]: > > > I'm also not a fan of this behavior, I actually stumbled across this > > > when tracking > > > down a bug the different radix usage caused. > > > > i'm interested in how this can cause a bug in correct software.
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.