[Perl/perl5] 3ed145: fix refcount on cloned constant state subs

2024-04-19 Thread iabyn via perl5-changes
  Branch: refs/heads/davem/state_leak
  Home:   https://github.com/Perl/perl5
  Commit: 3ed145ab00334466c0f1b3e7f342baf217083dd0
  
https://github.com/Perl/perl5/commit/3ed145ab00334466c0f1b3e7f342baf217083dd0
  Author: David Mitchell 
  Date:   2024-04-19 (Fri, 19 Apr 2024)

  Changed paths:
M pad.c
M t/op/state.t

  Log Message:
  ---
  fix refcount on cloned constant state subs

Perl was doing this:

$ perl -e'sub { CORE::state sub FOO () { 42 } }'
Attempt to free unreferenced scalar: ...
$

This warning was in particular now showing up on stderr on bleed builds:
ever since the recent addition of similar code to Deparse.t with
v5.39.9-33-g4a55343c55.

When a sub is made constant, it is converted into an XS sub, and the
IV(42) SV is stored in the CV's CvXSUBANY(cv).any_sv field.

But state subs (even const ones) get cloned if wrapped within an outer
anon sub and then that outer sub gets cloned. And it turns out that when
a const state sub is cloned, the ref count of that const SV wasn't being
incremented.

The fix is trivial. But there were two possible ways to fix it. The
approach I chose was to fix the cloning code so that it increments on
CvCONST(cv) being true in addition to on CvREFCOUNTED_ANYSV(cv) being
true.

The other approach (and arguably more logically correct) would be to set
the CVf_REFCOUNTED_ANYSV flag on const subs too, but this involves
modifying the code in multiple places, e.g.  newMYSUB(), newATTRSUB_x(),
newCONSTSUB_flags(), and makes it more likely that CPAN XS code out
there which cargo-cults similar code would also need fixing. So my fix
is simpler, more robust, but less satisfying.

Note that before 5.36.0, the failing code example above would segfault
rather than warn.



To unsubscribe from these emails, change your notification settings at 
https://github.com/Perl/perl5/settings/notifications


[Perl/perl5] f936cd: loc_tools.pl: Fix up Windows locale gathering

2024-04-19 Thread Karl Williamson via perl5-changes
  Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: f936cd91ee430786a1bb6068a4a7c8362610dd5f
  
https://github.com/Perl/perl5/commit/f936cd91ee430786a1bb6068a4a7c8362610dd5f
  Author: Karl Williamson 
  Date:   2024-04-19 (Fri, 19 Apr 2024)

  Changed paths:
M t/loc_tools.pl

  Log Message:
  ---
  loc_tools.pl: Fix up Windows locale gathering

The code previously didn't properly check for .ACP, .OCP, and .1252
locales, and as a result the attempts to check these were not the proper
syntax and so they didn't get tested.



To unsubscribe from these emails, change your notification settings at 
https://github.com/Perl/perl5/settings/notifications