Branch: refs/heads/smoke-me/khw-straight
  Home:   https://github.com/Perl/perl5
  Commit: ef845ab455d5aee17ea24b952c856d4a9bd1c7f4
      
https://github.com/Perl/perl5/commit/ef845ab455d5aee17ea24b952c856d4a9bd1c7f4
  Author: Karl Williamson <k...@cpan.org>
  Date:   2022-10-02 (Sun, 02 Oct 2022)

  Changed paths:
    M dist/threads/lib/threads.pm

  Log Message:
  -----------
  Bump threads version

I bumped 2 notches from 2.29 to 2.31 because there is a bug with 2.30,
where the 0 get swallowed, and it didn't seem pressing to investigate
and fix that.


  Commit: d6963c3d673ea2a5abbc12648679d8e81fa6e1e5
      
https://github.com/Perl/perl5/commit/d6963c3d673ea2a5abbc12648679d8e81fa6e1e5
  Author: Karl Williamson <k...@cpan.org>
  Date:   2022-10-02 (Sun, 02 Oct 2022)

  Changed paths:
    M sv.c

  Log Message:
  -----------
  sv.c: Move some code; consolidate

This moves the code for cloning the locale variables to a single place,
consolidating some that had the same cpp directives.  It showed that one
variable was cloned twice; the redundant one is now removed.


  Commit: 4c30eb65da4f49df72afe0dd87a1f773ed7b7b5e
      
https://github.com/Perl/perl5/commit/4c30eb65da4f49df72afe0dd87a1f773ed7b7b5e
  Author: Karl Williamson <k...@cpan.org>
  Date:   2022-10-02 (Sun, 02 Oct 2022)

  Changed paths:
    M sv.c

  Log Message:
  -----------
  sv.c: Clone interpreter with locale set to C

A thread is supposed to start with the locale set to the C locale.  We
were duping the parent values, and later overriding.  Better to set to C
from the beginning.


  Commit: 1fd8b339ba362a289c6cd93b21788c1ce39c7051
      
https://github.com/Perl/perl5/commit/1fd8b339ba362a289c6cd93b21788c1ce39c7051
  Author: Karl Williamson <k...@cpan.org>
  Date:   2022-10-02 (Sun, 02 Oct 2022)

  Changed paths:
    M sv.c

  Log Message:
  -----------
  sv.c: Set phase to CONSTRUCT on interpreter being cloned

So far this hadn't been an issue, but it will be for a future commit.


  Commit: bdea0f2b0aac9f72a93a6ee210cca7c7e6000ae8
      
https://github.com/Perl/perl5/commit/bdea0f2b0aac9f72a93a6ee210cca7c7e6000ae8
  Author: Karl Williamson <k...@cpan.org>
  Date:   2022-10-02 (Sun, 02 Oct 2022)

  Changed paths:
    M makedef.pl
    M perl.h

  Log Message:
  -----------
  Clean up perl.h/makedef.pl common logic

This has gotten two twisty little mazy over time.  Clean it up, add
comments, and make sure the logic is the same on both.


  Commit: 287e3f0f29bd801827d1c4ad060b1f3125758e23
      
https://github.com/Perl/perl5/commit/287e3f0f29bd801827d1c4ad060b1f3125758e23
  Author: Karl Williamson <k...@cpan.org>
  Date:   2022-10-02 (Sun, 02 Oct 2022)

  Changed paths:
    M perl.h

  Log Message:
  -----------
  Don't #define USE_THREAD_SAFE LOCALE unless threaded

If there aren't threads, yes locales are trivially thread-safe, but
the code that gets executed to make them so doesn't need to get
compiled, and that is controlled by this #define.


  Commit: 14cf10d53d2c743d64736d969dfa370a8264413a
      
https://github.com/Perl/perl5/commit/14cf10d53d2c743d64736d969dfa370a8264413a
  Author: Karl Williamson <k...@cpan.org>
  Date:   2022-10-02 (Sun, 02 Oct 2022)

  Changed paths:
    M embedvar.h
    M intrpvar.h
    M locale.c
    M makedef.pl
    M perl.c
    M perl.h
    M sv.c

  Log Message:
  -----------
  locale: Create special variable to hold current LC_ALL

Some configurations require us to store the current locale for each
category.  Prior to this commit, this was done in the array
PL_curlocales, with the entry for LC_ALL being in the highest element.

Future commits will need just the value for LC_ALL in some other
configurations, without needing the rest of the array.  This commit
splits off the LC_ALL element into its own per-interpreter variable to
accommodate those.  It always had to have special handling anyway beyond
the rest of the array elements,


  Commit: 2ea0079fed9a6d2edb810a6c3304cd9eec2c39cd
      
https://github.com/Perl/perl5/commit/2ea0079fed9a6d2edb810a6c3304cd9eec2c39cd
  Author: Karl Williamson <k...@cpan.org>
  Date:   2022-10-02 (Sun, 02 Oct 2022)

  Changed paths:
    M embed.fnc
    M embed.h
    M locale.c
    M proto.h

  Log Message:
  -----------
  locale.c: Compile display fcn under more circumstances

This is in preparation for it to be used in more instances in future
commits.  It uses a symbol that won't be defined until those commits.


  Commit: 6643f28629088b2c9237c9fb356d28b117730634
      
https://github.com/Perl/perl5/commit/6643f28629088b2c9237c9fb356d28b117730634
  Author: Karl Williamson <k...@cpan.org>
  Date:   2022-10-02 (Sun, 02 Oct 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  locale.c: Do uselocale() earlier in init process

This prevents some unnecessary steps, that the next commit would turn
into memory leaks.


  Commit: 489ad427b93ecf5674b76a530cc35148099f3ea1
      
https://github.com/Perl/perl5/commit/489ad427b93ecf5674b76a530cc35148099f3ea1
  Author: Karl Williamson <k...@cpan.org>
  Date:   2022-10-02 (Sun, 02 Oct 2022)

  Changed paths:
    M embedvar.h
    M intrpvar.h
    M locale.c
    M makedef.pl
    M perl.c
    M sv.c

  Log Message:
  -----------
  Some locale operations need to be done in proper thread

This is a step in solving #20155

The POSIX 2008 locale API introduces per-thread locales.  But the
previous global locale system is retained, probably for backward
compatibility.

The POSIX 2008 interface causes memory to be malloc'd that needs to be
freed.  In order to do this, the caller must first stop using that
memory, by switching to another locale.  perl accomplishes this during
termination by switching to the global locale, which is always available
and doesn't need to be freed.

Perl has long assumed that all that was needed to switch threads was to
change out tTHX.  That's because that structure was intended to hold all
the information for a given thread.  But it turns out that this doesn't
work when some library independently holds information about the
thread's state.  And there are now some libraries that do that.

What was happening in this case was that perl thought that it was
sufficient to switch tTHX to change to a different thread in order to do
the freeing of memory, and then used the POSIX 2008 function to change
to the global locale so that the memory could be safely freed.  But the
POSIX 2008 function doesn't care about tTHX, and actually was typically
operating on a different thread, and so changed that thread to the global
locale instead of the intended thread.  Often that was the top-level
thread, thread 0.  That caused whatever thread it was to no longer be in
the expected locale, and to no longer be thread-safe with regards to
localess,

This commit causes locale_term(), which has always been called from the
actual terminating thread that POSIX 2008 knows about, to change to the
global thread and free the memory.

It also creates a new per-interpreter variable that effectively maps the
tTHX thread to the associated POSIX 2008 memory.  During
perl_destruct(), it frees the memory this variable points to, instead of
blindly assuming the memory to free is the current tTHX thread's.

This fixes the symptoms associtated with #20155, but doesn't solve the
whole problem.  In general, a library that has independent thread status
needs to be updated to the new thread when Perl changes threads using
tTHX.  Future commits will do this.


  Commit: 64e25647f21e38915a88aef49acd54721110950a
      
https://github.com/Perl/perl5/commit/64e25647f21e38915a88aef49acd54721110950a
  Author: Karl Williamson <k...@cpan.org>
  Date:   2022-10-02 (Sun, 02 Oct 2022)

  Changed paths:
    M dist/threads/threads.xs
    M embed.fnc
    M locale.c
    M makedef.pl
    M perl.h
    M perlvars.h
    M proto.h
    M thread.h
    M util.c

  Log Message:
  -----------
  Switch libc per-interpreter data when tTHX changes

As noted in the previous commit, some library functions now keep
per-thread state.  So far the only ones we care about are libc
locale-changing ones.

When perl changes threads by swapping out tTHX, those library functions
need to be called with the new value so that they remain in sync with
what perl thinks the locale should be.

This commit creates a function to do this, and changes the
thread-changing macros to also call this as part of the change.

The commit also creates a mechanism to skip this during thread
destruction.  A thread in its death throes doesn't need to have accurate
locale information, and the information needed to map from thread to
what libc needs to know gets destroyed as part of those throes, while
relics of the thread remain.  I couldn't find a way to accurately know
if we are dealing with a relic or not, so the solution I adopted was to
just not switch during destruction.

This commit completes fixing #20155, EXCEPT for Windows boxes.  That
comes in the next commit.


  Commit: 8f9ed18f599f8daa26b4258a79fb38cb8a64d056
      
https://github.com/Perl/perl5/commit/8f9ed18f599f8daa26b4258a79fb38cb8a64d056
  Author: Karl Williamson <k...@cpan.org>
  Date:   2022-10-02 (Sun, 02 Oct 2022)

  Changed paths:
    M locale.c
    M makedef.pl
    M perl.h

  Log Message:
  -----------
  Sync Windows locale state with perl's threads

Like the POSIX 2008 locale functions, the modern Windows setlocale can
keep the current thread's locale state,  This is how it performs
thread-safe locale operations.  And it knows nothing of perl's tTHX
state.  So when perl swaps out the thread context the libc function must
be called so that the internal state is sync'd with the new context.

What we use for that state information is merely the current string of
what LC_ALL is.  (We keep the same string for POSIX 2008 implementations
that lack querylocale().)  When the locale changes because of the thread
context changing, setlocale() is called with the proper value of LC_ALL.
The code is already in place to free the memory the string occupies when
done.


  Commit: 43515c25a51ab17c5af3d1562a053a0ac66e7d08
      
https://github.com/Perl/perl5/commit/43515c25a51ab17c5af3d1562a053a0ac66e7d08
  Author: Karl Williamson <k...@cpan.org>
  Date:   2022-10-02 (Sun, 02 Oct 2022)

  Changed paths:
    M locale.c

  Log Message:
  -----------
  Revert code changes for Workaround for attributes.pm breakage

This partially reverts ebb1d9ce1d2cad3a1ef580148b3788cba3524319.

The real fix for this problem has now been committed, so the workaround
can be reverted, leaving the tests.


Compare: https://github.com/Perl/perl5/compare/ef845ab455d5%5E...43515c25a51a

Reply via email to