develooper Front page | perl.perl5.porters | Postings from June 2019

Re: [perl #134172] commit 027471cf breaks t/op/sprintf2.t onFreeBSD-11

Thread Previous | Thread Next
Dave Mitchell
June 20, 2019 10:23
Re: [perl #134172] commit 027471cf breaks t/op/sprintf2.t onFreeBSD-11
Message ID:
On Tue, Jun 11, 2019 at 06:30:21AM -0700, Hugo van der Sanden via RT wrote:
> I've looked some more today, and I think a larger change would be
> merited, but I'd want some input from DaveM and Karl.
> I feel the problems here are essentially a clash between the work from
> bc37e90eb: "Perl_sv_vcatpvfn_flags: set locale at most once" and from
> e9bc6d6b: "Add thread-safe locale handling". Because of the mutex
> requirements of the latter, attempting to retain the former will need us
> to identify every possible route out of sv_vcatpvfn - not only the
> explicit croaks, but also eg any attempt to read an SV that might be
> tied or overloaded.
> I don't think that's a practical thing to do; as such, I'm not convinced
> there's a practical route to getting correct mutex-protected locale
> changes on the platforms that need it while retaining the "do this only
> once" performance benefits.

I have no objection to making it potentially switch locales for each
call to snprintf.

> What I'm not sure of is whether _some_ of the "only once" benefits can
> be retained, eg to discover if switching is necessary - I suspect that
> subsidiary code (such as tied and overloaded arguments, again) might
> make that unsafe even in an unthreaded application.

From my commit message in bc37e90eb, it appears that checking whether
we're within the lexical scope of 'use locale' is the expensive bit. That
can't change during the course of executing the function, so it looks like
a good candidate for checking only once. I guess it's the IN_LC() bit of

Spock (or Data) is fired from his high-ranking position for not being able
to understand the most basic nuances of about one in three sentences that
anyone says to him.
    -- Things That Never Happen in "Star Trek" #19

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About