You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use Devel::Peek;
#use Inline ('force', 'noclean');
use Inline C => Config =>
PRE_HEAD => '#define PERL_NO_GET_CONTEXT 1';
use Inline C => Config => BUILD_NOISY => 1;
use Inline C => <<'END_OF_C_CODE';
SV* do3(SV* ssv) {
dTHX;
U32 flags = 0;
SV* dsv;
if ((SvFLAGS(ssv) & ((SVf_OK|SVs_GMG) &~(SVp_NOK))) == SVf_NOK)
dsv = newSVnv(SvNVX(ssv));
else if ((SvFLAGS(ssv) & ((SVf_OK|SVs_GMG) &~(SVp_IOK))) == SVf_IOK) {
IV iv = SvIVX(ssv);
dsv = SvUOK(ssv) ? newSVuv((UV)iv) : newSViv(iv);
}
else {
U32 type = SvPOK(ssv) ? SVt_PV : SvNOK(ssv) ? SVt_NV : SVt_IV;
if (flags & SVs_TEMP)
dsv = newSV_type_mortal(type);
else
dsv = newSV_type(type);
sv_dump_depth(dsv, 3);
sv_dump_depth(ssv, 3);
sv_setsv_flags(dsv, ssv, SV_GMAGIC | SV_NOSTEAL
| SV_COW_SHARED_HASH_KEYS | SV_COW_OTHER_PVS | SV_DO_COW_SVSETSV);
sv_dump_depth(ssv, 3);
sv_dump_depth(dsv, 3);
return dsv;
}
if (flags & SVs_TEMP)
dsv = sv_2mortal(dsv);
return dsv;
}
END_OF_C_CODE
$, = "\n";
use v5.30;
use strict;
use warnings;
#$DB::single = 1;
#$DB::single = 1;
use version;
my $s1;
my $s2;
my $s3;
my $s4;
warn "\nwith 8 bytes\n\n";
$s1 = substr(int(rand(10)),0,1).'.345678';
$s2 = do3($s1);
warn "\nnow with 9 bytes\n\n";
$s1 = substr(int(rand(10)),0,1).'.3456789';
$s3 = do3($s1);
warn "\nwith 4 bytes\n\n";
$s1 = substr(int(rand(10)),0,1).'.34';
$s4 = do3($s1);
with 8 bytes
SV = PV(0x2abb18) at 0x2ab0f0
REFCNT = 1
FLAGS = ()
PV = 0
SV = PV(0x2abae8) at 0x244ce88
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x231e048 "4.345678"\0
CUR = 8
LEN = 16
SV = PV(0x2abae8) at 0x244ce88
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x231e048 "4.345678"\0
CUR = 8
LEN = 16
SV = PV(0x2abb18) at 0x2ab0f0
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x2496e98 "4.345678"\0
CUR = 8
LEN = 16
now with 9 bytes
SV = PV(0x2abb48) at 0x2ab0f0
REFCNT = 1
FLAGS = ()
PV = 0
SV = PV(0x2abae8) at 0x244ce88
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x231e048 "7.3456789"\0
CUR = 9
LEN = 16
SV = PV(0x2abae8) at 0x244ce88
REFCNT = 1
FLAGS = (POK,IsCOW,pPOK)
PV = 0x231e048 "7.3456789"\0
CUR = 9
LEN = 16
COW_REFCNT = 1
SV = PV(0x2abb48) at 0x2ab0f0
REFCNT = 1
FLAGS = (POK,IsCOW,pPOK)
PV = 0x231e048 "7.3456789"\0
CUR = 9
LEN = 16
COW_REFCNT = 1
with 4 bytes
SV = PV(0x2abb68) at 0x2ab0f0
REFCNT = 1
FLAGS = ()
PV = 0
SV = PV(0x2abae8) at 0x244ce88
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x2495098 "8.34"\0
CUR = 4
LEN = 16
SV = PV(0x2abae8) at 0x244ce88
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x2495098 "8.34"\0
CUR = 4
LEN = 16
SV = PV(0x2abb68) at 0x2ab0f0
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x2497018 "8.34"\0
CUR = 4
LEN = 16
Expected behavior
That tiny strings can SVPV 255 COW. 8 bytes and under are often tokens/fields/keys/prop names/string-ified integers/stringified 1 or 0 bools/api func calls or var names/json prop names. All of those are very high frequency to see bounce around at runtime on end user code.
Perl_sv_grow()/PERL_STRLEN_ROUNDUP/PERL_STRLEN_EXPAND_SHIFT/PERL_STRLEN_NEW_MIN/newSVpvn/etc should not be discriminating against short strings held in Perl API's Newx() backed, API min buf length of 0x10==SvLEN().
Description
from sv.c
8 bytes or smaller strings can't 255 COW because of ^^^^^ added in 5.19.12 in
#13800
e8c6a47
Author: Yves Orton [email protected]
Date: 5/11/2014 6:37:33 AM
Message:
Implement "max waste" thresholds to avoid problems with COW and deliberately overallocated pvs
https://rt.perl.org/Ticket/Display.html?id=121796
Steps to Reproduce
Expected behavior
That tiny strings can SVPV 255 COW. 8 bytes and under are often tokens/fields/keys/prop names/string-ified integers/stringified 1 or 0 bools/api func calls or var names/json prop names. All of those are very high frequency to see bounce around at runtime on end user code.
Perl_sv_grow()
/PERL_STRLEN_ROUNDUP
/PERL_STRLEN_EXPAND_SHIFT
/PERL_STRLEN_NEW_MIN
/newSVpvn
/etc should not be discriminating against short strings held in Perl API's Newx() backed, API min buf length of 0x10==SvLEN().Perl configuration
The text was updated successfully, but these errors were encountered: