Branch: refs/heads/smoke-me/khw-attributes Home: https://github.com/Perl/perl5 Commit: a444ce4a443513bfb72afc94c9b02a7d4fbeb1b7 https://github.com/Perl/perl5/commit/a444ce4a443513bfb72afc94c9b02a7d4fbeb1b7 Author: Karl Williamson <k...@cpan.org> Date: 2022-10-03 (Mon, 03 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: 951401808d5246ab4dd6b3d09db8dad8321479e9 https://github.com/Perl/perl5/commit/951401808d5246ab4dd6b3d09db8dad8321479e9 Author: Karl Williamson <k...@cpan.org> Date: 2022-10-03 (Mon, 03 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: b3a6083cf30aacfba161030915e2907ff9213dc5 https://github.com/Perl/perl5/commit/b3a6083cf30aacfba161030915e2907ff9213dc5 Author: Karl Williamson <k...@cpan.org> Date: 2022-10-03 (Mon, 03 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: 3e7efd444621836dbbce87795b6226ca5acfea2b https://github.com/Perl/perl5/commit/3e7efd444621836dbbce87795b6226ca5acfea2b Author: Karl Williamson <k...@cpan.org> Date: 2022-10-03 (Mon, 03 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: 74c95074cf94e10eb11c4aedc3dd84691ec1f87c https://github.com/Perl/perl5/commit/74c95074cf94e10eb11c4aedc3dd84691ec1f87c Author: Karl Williamson <k...@cpan.org> Date: 2022-10-03 (Mon, 03 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: b4b117200e149afa4490fac64d71ba9cd24bbcdc https://github.com/Perl/perl5/commit/b4b117200e149afa4490fac64d71ba9cd24bbcdc Author: Karl Williamson <k...@cpan.org> Date: 2022-10-03 (Mon, 03 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: 2b5690eacff0eba313a0dca49a52351b230dbf18 https://github.com/Perl/perl5/commit/2b5690eacff0eba313a0dca49a52351b230dbf18 Author: Karl Williamson <k...@cpan.org> Date: 2022-10-03 (Mon, 03 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: cdd581f6ccf9f149be1860d785bc26513d39d75a https://github.com/Perl/perl5/commit/cdd581f6ccf9f149be1860d785bc26513d39d75a Author: Karl Williamson <k...@cpan.org> Date: 2022-10-03 (Mon, 03 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: 3d6d6d28547ec2eab0344632dd1c8ae528e503da https://github.com/Perl/perl5/commit/3d6d6d28547ec2eab0344632dd1c8ae528e503da Author: Karl Williamson <k...@cpan.org> Date: 2022-10-03 (Mon, 03 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: f514e6898a79bb715c74cd934bf6ff7bb0658ec1 https://github.com/Perl/perl5/commit/f514e6898a79bb715c74cd934bf6ff7bb0658ec1 Author: Karl Williamson <k...@cpan.org> Date: 2022-10-03 (Mon, 03 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 informed about 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. For POSIX 2008, the function just calls uselocale() using the per-interpreter object introduced previously. For Windows, this commit adds a per-interpreter string of the current LC_ALL, and the function calls setlocale on that. We keep the same string for POSIX 2008 implementations that lack querylocale(), so this commit just enables that variable on Windows as well. The code is already in place to free the memory the string occupies when done. 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. Commit: c0705fcc7a15dba903e3a703f86f994bcdd66196 https://github.com/Perl/perl5/commit/c0705fcc7a15dba903e3a703f86f994bcdd66196 Author: Karl Williamson <k...@cpan.org> Date: 2022-10-03 (Mon, 03 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/43515c25a51a...c0705fcc7a15