Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Wed, 11 Sep 2019 20:08:19 +0200
From: Jens Gustedt <jens.gustedt@...ia.fr>
Cc: musl@...ts.openwall.com
Subject: Re: printf doesn't respect locale

On Wed, 11 Sep 2019 11:38:53 -0400 Rich Felker <dalias@...c.org> wrote:

> On Wed, Sep 11, 2019 at 05:15:45PM +0200, Jens Gustedt wrote:
> > Do you think that a highlevel implementation using _Thread_local or
> > (tss calls) and setlocale would be doable, such that we could even
> > provide a reference implementation for all POSIX systems that also
> > implement some form of thread local variables?  
> 
> It can't be done in terms of setlocale because setlocale is not
> thread-safe or thread-local. It could be done in terms of POSIX
> uselocale, but such an implementation would not be fail-safe -- it
> needs to be able to allocate a locale_t object via duplocale, since
> the uselocale API works with a locale_t objects that describe the
> value of *all* locale categories, rather than the categories being
> individually settable on a per-thread basis (this is a design flaw in
> the POSIX interfaces, and the historic xlocale ones they were based
> on, IMO).

Ok, yes this sounds too complicated.

> So such an implementation could be a pseudo-code/demo of the
> functionality, but I think I'd want the proposed functionality to be
> always-succeeds to discourage erroneous code that ignores the result
> (resulting in wrong formatting/parsing, which is unsafe) or aborts the
> program (eew).

Yes, "can't fail" is an important property for such a function. This
should be part of the normative requirement, then.

Jens

-- 
:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536   ::
:: :::::::::::::::::::::: gsm France : +33 651400183   ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

Content of type "application/pgp-signature" skipped

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.