| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
EVAL was calling regcppush twice per invocation, once before executing the
callback, and once after. But not regcppop'ing twice. So each time we
would accumulate an extra "frame" of data. This is/was hidden somewhat by
the way we eventually "blow" the stack, so the extra data was just thrown
away at the end.
This removes the second set of pushes so that the save stack stays a stable
size as it unwinds from each failed eval.
We also weren't cleaning up after a (?{...}) when we failed to match to its
right. This unwinds the stack and restores the parens properly.
This adds tests to check how the save stack grows during patterns using
(?{ ... }) and (??{ ... }) and ensure that when we backtrack and re-execute
the EVAL again it cleans up the stack as it goes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The api for av_store() says it is the callers responsibility to call
SvREFCNT_inc() on the stored item after the store is successful.
However inside of av_store() we store the item in the C level array before we
trigger magic. To a certain extent this is required because mg_set(av) needs
to be able to see the newly stored item.
But if the mg_set() or other magic associated with the av_store() operation
fails, we would end up with a double free situation, as we will long jump up
the stack above and out of the call to av_store(), freeing the mortal as we go
(via Perl_croak()), but leaving the reference to the now freed pointer in the
array. When the next SV is allocated the reference will be reused, and then we
are in a double free scenario.
I see comments in pp_aassign talking about defusing the temps stack for the
parameters it is passing in, and things like this, which at first looked
related. But that commentary doesn't seem that relevant to me, as this bug
could happen any time a scalar owned by one data structure was copied into an
array with set magic which could die. Eg, I can easily imagine XS code that
expected code like this (assume it handles magic properly) to work:
SV **svp = av_fetch(av1,0,1);
if (av_store(av2,0,*svp))
SvREFCNT_inc(*svp);
but if av2 has set magic and it dies the end result will be that both av1 and
av2 contain a visible reference to *svp, but its refcount will be 1. So I think
this is a bug regardless of what pp_aassign does.
This fixes https://github.com/Perl/perl5/issues/20675
|
|
|
|
|
|
|
|
|
| |
The old code used a regex that would split on exactly one space, so if
the data was changed to have more than one then it would get absorbed
into the name that was parsed out of the header file, leading the code
to test for things like "FOO ", which of course don't exist. Likely this
could have caused other issues too, but the defines in practice are
single symbols.
|
|
|
|
|
|
|
|
| |
They are similar to SVf and SVf_QUOTEDPREFIX but take an HV * argument
and use HvNAME() and related macros to extract the string. This is
helpful as it makes constructing error messages from a stash (HV *)
easier. It is the callers responsibility to ensure that the HV is
actually a stash.
|
|
|
|
|
|
|
|
|
| |
The api for amagic_find() didnt make as much as sense as we thought
at first. Most people will be using this as a predicate, and don't
care about the returned CV, so to simplify things until we can really
think this through the required API this switches it to return
a bool and renames it to amagic_applies(), as in "which amagic_applies
to this sv".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes GH #20565.
Lack of tests allowed sync_locale() to get broken until CPAN testing
showed it so.
Basically, I blew it in 9f5a615be674d7663d3b4719849baa1ba3027f5b. Most
egregiously, I forgot to turn back on when a sync_locale() is executed,
the toggling for locales whose radix character isn't a dot. And this
needs a way to tell the other code that it needs to recompute things at
this time, since our records don't reflect what happened before the
sync.
|
|
|
|
|
|
| |
API switch_to_global_locale() and sync_locale() weren't tested because I
hadn't figured out a way to do so, but @dk showed me the way in his
reproducing case for GH #20565.
|
|
|
|
|
|
|
|
|
|
|
| |
Prior to this commit there was code (whose results were ignored) looking
for a locale with a non-dot radix. This can result in a UTF-8 radix,
which may not display properly without the terminal and file handle
being in sync. Almost all non-dot locales use a comma, which is
represented the same in UTF-8 as not, so doesn't suffer from the display
problem. So look specifically for a comma.
The result is still unused, but the next commit will use it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Prior to this commit, when hopping forwards, and the initial position to
hop from is a continuation byte, it treats it and each such successive
one as a single character until it gets to a start byte, and switches
into normal mode.
In contrast, in hopping backwards, all the consecutive continuation
bytes are considered to be part of a single character (as they indeed
are).
Thus there is a discrepancy between forward/backwards hopping; and the
forward version seems wrong to me.
This commit removes the discrepancy. There is no change in behavior if
the starting position is to the beginning of a character. All calls in
the core except for the API test are of this form.
But, if the initial position is in the middle of a character, it now
moves to the beginning of the next character, subtracting just 1 from
the count of characters to hop (instead of subtracting however many
continuation bytes there are). This is how I would have expected it to
work all along.
Succinctly, getting to the next character now consumes one hop count, no
matter the direction nor which byte in the character is the starting
position.
|
|
|
|
| |
And stop skipping it
|
|
|
|
| |
Oversight in b17e77fbd8
|
|
|
|
|
|
|
|
|
|
|
| |
These macros have limited use in core:
- only Socket uses SvPVbyte_nomg()
- nothing uses SvPVutf8_nomg()
Update the existing tests to ensure len is set properly.
Related to #20507
|
|
|
|
|
|
|
|
|
| |
gcc 12 was complaining that evaluating (somehekptr)->hek_key
was always true in many places where HvNAME() or HvENAME() was
being called in boolean context.
Add new macros to check whether the names should be available and
use those instead.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This set of PUSH-style macros takes a string literal argument and pushes
it to the stack, optionally mortalizing it and/or extending the stack.
Previously, the best alternative was
mPUSHp("literal", 7);
which required the author to visually count the number of characters in
the string literal (7 in this case). These new macros fit the similar
pattern familiar to many functions such as `newSVpvs`, which takes a
string literal and counts it directly.
|
|
|
|
|
|
|
|
| |
If this flag is set, then the CvXSUBANY(cv).any_sv pointer will have its
reference count decremented when the CV itself is freed. This is useful
for XS extensions that wish to store extra data in here. Without this
flag, such extensions have to resort to using magic with a 'free'
function to perform this work.
|
|
|
|
|
| |
If no LC_ALL, there won't be an LC_ALL() sub. Instead use the string
'LC_ALL" and an explicit check to see if it is there.
|
|
|
|
|
|
|
|
| |
Make this recently-added test function always return something,
so that assigning its return value to a scalar variable doesn't underflow
the stack.
(I spotted this while debugging something else.)
|
| |
|
|
|
|
|
| |
This is a follow on to 0e647b0520a120213d2074ede2609a10076f2f8d, to
finish changing the variable names to not be as confusing.
|
|
|
|
|
|
| |
These for hopping within a string had two items whose name both
contained 'offset', confusing things. One of them is the number of
characters to hop. Rename for clarity.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
GH #19188
in something like
sub foo { goto &xs_sub }
if the XS subroutine tries to get its caller context using GIMME_V,
it used to always be reported as scalar, since the OP_GOTO is the
current op being executed, and that op is marked as scalar.
The correct answer should be to return the context of the caller of
foo(), but that information is lost as, just before calling the XS sub,
pp_goto pops the CXt_SUB off the context stack which holds the recorded
value of the context of the caller.
The fix in principle is for goto, just before calling the XS sub, to
grab the gimme value from the about-to-be-popped CXt_SUB frame, and set
OP_GOTO op's op_flag field with that gimme value.
However, modifying ops at runtime isn't allowed, as ops are shared
between threads. So instead set up a fake copy of the OP_GOTO and alter
the gimme value in that instead.
I'm pretty confident that on an exception, a LEAVE_SCOPE() will always
be done before the JMPENV_JUMP(), so PL_op will be restored to its
original value *before* the CPU stack is restored to it's old value
(leaving the temporary OP_GOTO as garbage in an abandoned stack frame).
|
| |
|
|
|
|
|
|
|
| |
This reverts commit d6ad3b72778369a84a215b498d8d60d5b03aa1af
and adds comments that it existed. This is so that this work which
isn't really needed based on current usage in core isn't lost, and can
be used in the future.
|
|
|
|
|
|
|
| |
This should speed up backing up a large distance in a UTF-8 string. But
we don't actually do that in core. I did this work 5 years ago before I
realized this. Rather than throw it away, this commit gets it into the
history, and the next commit will revert it.
|
|
|
|
|
|
| |
With the explicit flush this test will fail when PERLIO=stdio, because
stdio defaults to block-based buffering on pipes and therefore the
output will come out wrong.
|
|
|
|
|
|
| |
We do not have any tests for the bool internals. This creates a bunch of
them to test and validate the various new API calls for creating and
setting bools.
|
|
|
|
|
|
|
|
| |
This test fails on EBCDIC systems, because it wants a non-ASCII
character, and the one it chose, E9, is ASCII on EBCDIC ('Z').
perlhacktips suggests B6 as a character to use in such tests, and this
commit changes to use that.
|
|
|
|
| |
Perl core itself seems not to call my_strtod, so test it with XS::APItest.
|
|
|
|
|
|
| |
We know how grok results should vary with and without PERL_SCAN_TRAILING
both for inputs with trailing garbage and those without, so abstract
that out and test both cases for each input.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Consistently honour what the docs have always promised:
If an infinity or a not-a-number is recognized, C<*sp> will point to
one byte past the end of the recognized string. If the recognition fails,
zero is returned, and C<*sp> will not move.
Additionally, restore Perl_grok_number_flags to allowing inf/nan with
trailing garbage only when called with PERL_SCAN_TRAILING; add notes
to the other two core callers to clarify that they always accept such
trailing garbage.
A small number of XS-APItest tests were modified to reflect the stricter
behaviour: "Infin" and "nanx" are now invalid without PERL_SCAN_TRAILING.
|
|
|
|
|
|
|
| |
This macro relied on a now-removed other macro in 2019,
216dc346ceeeb9b6ba0fdd470ccfe4f8b2a286c4. Fix it and add tests.
This bug was caught by Devel::PPPort
|
| |
|
| |
|
| |
|
|
|
|
| |
passed
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
This effectively reverts 3ece276e6c0.
It turns out this was a bad idea to make U mean the non-native official
Unicode code points. It may seem to make sense to do so, but broke
multiple CPAN modules which were using U the previous way.
This commit has no effect on ASCII-platform functioning.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
the eq_set, eq_hash, and eq_array functions in Test::More are
discouraged to use, and is_deeply is recommended. Ref:
https://metacpan.org/pod/Test::More#Discouraged-comparison-functions
The reason for this is that, if the tests fail, is_deeply has much
better diagnostics.
The other thing is that is_deeply is a test function directly, where
eq_hash and such need to be wrapped inside ok(). This is easy to forget
-- proof of this is in Benchmark.t, where we had this code, that did not
test anything:
eq_set([keys %$got], [qw(Foo Bar Baz)], 'should be exactly three objects');
It is now replaced by:
is_deeply([sort keys %$got], [sort qw(Foo Bar Baz)], 'should be exactly three objects');
this commit replaces all usage of eq_set, eq_hash, and eq_array in lib/
and ext/ for tests that use Test::More.
One small exception is where a negated test is used; Test::More does not
have is_not_deeply() or such. Test2 has `isnt()` for this, but that is
not in core. In those cases, we still keep using the eq_ operators.
|
| |
|
| |
|
|
|
|
|
| |
Defining this macro causes newHV() to create hashes without shared hash key
scalars. The default is that hashes are created with shared hash keys.
|
|
|
|
|
|
| |
The longer name more accurately reflects what the constant refers to.
Correct the comments describing how some arena roots are re-used.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This code path only affects symbol tables, and can't be reached by regular
Perl code. It is only reachable using the XS API to delete a key from a
stash where the key was in the 8-bit range but passed in UTF-8 encoded.
This has been in the code since it was added in Oct 2010 by commit
35759254f69c7bfa:
Rename stashes when they move around
Also there is no need to call SvPV() on keysv in S_hv_delete_common() as
its caller has always already done this. This entire code is not KISS.
|
|
|
|
|
| |
Copy the Scalar::Util::isbool() tests into XS-APItest so we can avoid relying
on Scalar::Util just to check core functionality
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The two API test wrappers utf16_to_utf8_reversed() and
utf8_to_utf16(_reversed() included a call to SvPV_force_nolen(), because
the underlying functions in utf8.c which they were wrapping used to
modify the src buffer.
However since v5.35.2-236-g5fd26678bf, these functions no longer modify
the buffer, so the force is superfluous. So this commit removes force.
As a side-effect, this fixes a failure in
cd t; ./TEST -deparse ../ext/XS-APItest/t/utf16_to_utf8.t
because the test file has this line:
$utf16_of_U10302 = utf8_to_utf16_reversed(chr 0x10302);
which after a round trip through deparse becomes:
$utf16_of_U10302 = utf8_to_utf16_reversed("\x{10302}");
and it so happens that at compile time, the chr() form gets constant-
folded into a modifiable PADTMP string constant, which survives a call
to SvPV_force(), while the latter form is a pure read-only constant SV
which croaks with "Modification of a read-only value attempted"
|