mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: Daniel Schoepe <daniel@schoepe.org>
Cc: musl@lists.openwall.com
Subject: Re: printf doesn't respect locale
Date: Tue, 10 Sep 2019 20:43:12 +0200	[thread overview]
Message-ID: <20190910184312.GJ22009@port70.net> (raw)
In-Reply-To: <CAPy=dbLiUm_H22myz9LBkiSVv+4vv0B7t5RMD+i=mDWYeqJ=pg@mail.gmail.com>

* Daniel Schoepe <daniel@schoepe.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@port70.net> wrote:
> >
> > * Daniel Schoepe <daniel@schoepe.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.


  parent reply	other threads:[~2019-09-10 18:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-09 16:31 Daniel Schoepe
2019-09-09 16:39 ` Daniel Schoepe
2019-09-09 16:51 ` Szabolcs Nagy
2019-09-09 17:55   ` Rich Felker
2019-09-09 17:54 ` Rich Felker
2019-09-10 16:00   ` Daniel Schoepe
2019-09-10 16:31     ` Szabolcs Nagy
2019-09-10 16:44       ` Tim Tassonis
2019-09-10 17:30         ` Rich Felker
2019-09-10 17:10       ` Daniel Schoepe
2019-09-10 17:33         ` Rich Felker
2019-09-10 18:43         ` Szabolcs Nagy [this message]
2019-09-10 21:55           ` A. Wilcox
2019-09-11 10:01             ` Szabolcs Nagy
2019-09-11 10:07               ` Jens Gustedt
2019-09-11 11:44                 ` Rich Felker
2019-09-11 12:53                   ` Jens Gustedt
2019-09-11 13:47                     ` Rich Felker
2019-09-11 15:15                       ` Jens Gustedt
2019-09-11 15:38                         ` Rich Felker
2019-09-11 18:08                           ` Jens Gustedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190910184312.GJ22009@port70.net \
    --to=nsz@port70.net \
    --cc=daniel@schoepe.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).