| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
It's possible that the referencing SV is being freed partway through the
freeing of reference target. If this happens, the backreferences array of
the target has already been freed, and so svp will be NULL. If this is the
case, do nothing and return. Previously, this condition was not recognised
and the code would panic.
|
|
|
|
|
|
|
|
|
|
| |
During global destruction, it's possible for the array containing
backreferences to be freed before the SV that owns it. If this happens, don't
mistake it for a scalar backreference stored directly, and then get confused
and panic because things seem inconsistent.
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2011-12/msg00039.html
gives more information.
|
|
|
|
|
|
| |
If panicing with a croak(), include in the panic message the values which
caused the croak. This reveals something about the cause of the panic, and
more subtly, which of the two possible panic locations this is.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
unless they are orphaned.
This commit stops globs that still reside in their stashes from being
cloned during a join.
That way, a sub like sub{$::x++}, when cloned into a subthread and
returned from it, will still point to the same $::x.
This commit takes the conservative approach of copying on those globs
that can be found under their names in the original thread.
While this doesn’t work for all cases, it’s probably not possible to
make it work all the time.
|
|
|
|
|
|
|
| |
It was using the internal byte count instead of the number of charac-
ters. The iatter is documented. The former is useless, even for C
code calling this, as later arguments could cause the current buffer
to be upgraded to utf8, throwing off any offsets returned.
|
|
|
|
|
| |
In two instances, I actually modified to code to avoid %s for a
constant string, as it should be faster that way.
|
|
|
|
| |
It is already documented in perldiag with the right spelling.
|
|
|
|
|
| |
so that splain can find the message even when there is no op
mentioned.
|
|
|
|
|
|
|
| |
Some compilers complain, because -1 is being assigned to an unsigned
variable. This variable is not actually used before being assigned
to, but we have to initialise it as some other compilers cannot
detect that.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This code in sv_setsv, introduced in ece467f9b3, can’t possi-
bly be right:
if ( SvVOK(dstr) )
{
/* need to nuke the magic */
mg_free(dstr);
}
And here is a test to prove it:
sub TIESCALAR { bless[]}
sub STORE {}
tie $@, "";
$@ = v0;
warn tied $@; # main=ARRAY(0xc0ffee)
$@ = 3;
warn tied $@; # something’s wrong
It blows away tiedness.
You could do that to any variable.
Let’s see:
$! = v0;
$! = 3;
open foo, 'oentuhaeontu' or die $!; # 3 at - line 3.
Youch!
Let’s just free vstring magic, shall we?
|
|
|
|
| |
This is something I missed in 804b5ed7.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Code like this can cause PL_last_in_gv to point to a coercible glob:
$f{g} = *STDOUT;
readline $f{g};
If $f{g} is then modified such that it is no longer a glob,
PL_last_in_gv ends up pointing to a non-glob:
$f{g} = 3;
If $f{g} is freed now, the PL_last_in_gv-nulling code in sv_clear will
be skipped, as it only applies to globs.
undef %f; # now PL_last_in_gv points to a freed scalar
The resulting freed scalar can be reused by another handle,
*{"foom"} = *other;
causing tell() with no arguments to return the position on *other,
even though *other was no the last handle read from.
This commit fixes it by nulling PL_last_in_gv when a coercible glob
is coerced.
|
|
|
|
| |
Without the ‘in %s’ it covers both forms of the error message.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The following paragraph is in perlguts.pod:
To check if you've got an object derived from a specific class you have
to write:
if (sv_isobject(sv) && sv_derived_from(sv, class)) { ... }
which does the right thing with magical things like tied scalars.
Signed-off-by: David Golden <dagolden@cpan.org>
|
|
|
|
|
| |
Note that the string must be the start of a mallocked block of memory,
and not a pointer to the middle of it.
|
|
|
|
|
|
|
|
|
|
|
| |
This was copied from sv_usepvn_flags in commit 58b643af9. It is
unnecessary, and probably incorrect, as heks are not tainted.
Why sv_sethek used sv_usepvn_flags to begin with I don’t know, but I
imagine it was for brevity’s sake. This code was ultimately derived
from newSVhek, which doesn’t use sv_usepvn_flags. Because of that,
and because it is now far enough removed from sv_usepvn_flags, I have
removed the comment referring to it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
sv_usepvn_flags assumes that ptr is at the head of a block
of memory allocated by malloc. If perl's malloc is in use,
the data structures malloc uses and the data allocated for
perl are intermixed, and accounting done by malloced_size
in sv_usepvn_flags will overwrite valid memory if its called
on an address that is not the start of a malloced block.
The actual work being accomplished by sv_usepvn_flags, and
not undone immediately after by sv_sethek, is limited to 3 calls
on the SV. Inlining those calls removes the dependency on malloc.
This fixes perl #104034.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This logic in sv_magic is wrong:
if (SvREADONLY(sv)) {
if (
/* its okay to attach magic to shared strings; the subsequent
* upgrade to PVMG will unshare the string */
!(SvFAKE(sv) && SvTYPE(sv) < SVt_PVMG)
&& IN_PERL_RUNTIME
&& !PERL_MAGIC_TYPE_READONLY_ACCEPTABLE(how)
)
{
Perl_croak_no_modify(aTHX);
}
}
There is nothing wrong with attaching magic to a shared string that
will stay shared. Also, shared strings are not always < SVt_PVMG.
Sometimes a PVMG or PVLV can end up with a shared string. In those
cases, the logic above treats them as read-only, which they ain’t.
The easiest example is a downgraded typeglob:
$x = *foo; # now a PVGV
undef $x ; # downgraded to PVMG
$x = __PACKAGE__; # now a shared string (COW)
tie $x, "main"; # bang! $x is considered read-only
sub main::TIESCALAR{bless[]}
|
|
|
|
|
|
| |
Now that SvOOK_on has a usable definition (i.e., it leaves the
NIOK flags alone), we can use it and remove the comments warning
against it.
|
| |
|
|
|
|
|
| |
Hopefully this explanation will be clearer and will prevent clumsy
individuals like me from introducing bugs like #103766.
|
| |
|
| |
|
|
|
|
|
| |
S_sv_unglob is only called in one place, so inline it (but cheat, to
preserve blame history).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There is this special SV_COW_DROP_PV flag that gets passed to
sv_force_normal_flags to signal that the SV is about to be clobbered,
so there is no point in allocating a new PV. But this flag was not
actually being used, until the previous commit commandeered it for
globs (despite the name).
Now it actually does what it says.
Before and after:
$ time ./perl -e '$x = __PACKAGE__, undef $x for 1..8000000'
real 0m5.758s
user 0m5.740s
sys 0m0.008s
$ time ./perl -e '$x = __PACKAGE__, undef $x for 1..8000000'
real 0m3.290s
user 0m3.282s
sys 0m0.006s
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
sv_force_normal is passed the SV_COW_DROP_PV flag if the scalar is
about to be written over. That flag is not currently used. We can
speed up assignment over fake GVs a lot by taking advantage of the flag.
Before and after:
$ time ./perl -e '$x = *foo, undef $x for 1..2000000'
real 0m4.264s
user 0m4.248s
sys 0m0.007s
$ time ./perl -e '$x = *foo, undef $x for 1..2000000'
real 0m1.820s
user 0m1.812s
sys 0m0.005s
|
|
|
|
|
|
| |
sysread uses SvPV_force, which has a bug in it. Even if the SV_GMAGIC
flag is passed to sv_pvn_force_flags (which SvPV_force does), it
ignores magic in any typeglob argument.
|
|
|
|
| |
See perl #102586.
|
| |
|
|
|
|
|
| |
As amagic_deref_call pushes a new stack, PL_stack_sp will always have
the same value before and after, so SPAGAIN is unnecessary.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This code:
"@{[ $x ]}"
was producing the warning:
Use of uninitialized value $" in join or string at -e line 1.
erroneously, as of commit 6d1f0892c.
Commit 6d1f0892c was meant to fix bug #72090, which caused the varia-
ble to be mentioned even for the > warning in this instance:
$ ./perl -we '$a = @$a > 0'
Use of uninitialized value $a in array dereference at -e line 1.
Use of uninitialized value $a in numeric gt (>) at -e line 1.
The fix for #72090 was wrong, because the loop that it modified loops
through the kid ops, finding out how many candidates there are. If
there is only one candidate left, it is used. Skipping ops that could
be responsible for the undefined value just because we don’t want
to mention their variables is the wrong approach, at least in that
loop, as the blame will fall on whatever other op is left if there
is only one.
There is code further up to deal with the OP_RV2[AH]V case, that des-
cends explicitly into the child ops. This commit tweaks that code to
descend only for the top-level op, to allow @{ $x } to warn still
about an uninitialised value used in array dereference. Where @{...}
is an operand to the operator that is emitting the warning, we don’t
descend. That is how #72090 should have been fixed to begin with, as
it has no odd side effects.
This bug (#103766) affects any other cases where there are two oper-
ands and one is @{...} or %{...}:
$ perl5.15.4 -e 'use warnings "uninitialized"; $y = 6; $y + @{ $x }'
Use of uninitialized value $x in array dereference at -e line 1.
Use of uninitialized value $y in addition (+) at -e line 1.
$y is obviously not responsible there.
|
|
|
|
|
| |
I don’t know why this is necessary, but there are some strange
#defines surrounding this function.
|
|
|
|
|
|
|
|
|
|
| |
The logic surrounding subroutine redefinition warnings (to warn or not
to warn?) was in three places. Over time, they drifted apart, to the
point that newXS was following completely different rules. It was
only warning for redefinition of functions in the autouse namespace.
Recent commits have brought it into conformity with the other redefi-
nition warnings.
Obviously it’s about time we put it in one function.
|
|
|
|
|
|
|
|
|
|
|
| |
In perldiag, this is listed as (S), which means that outside of any
use/no warnings scope it always warns, regardless of $^W.
But this warning was ignoring use/no warnings, too.
There were actually tests for this oddity, but I think those were
added by mistake, or this was just not thought through. I cannot see
how this is not a bug.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This speeds things up 2.8 times in my naïve benchmarks.
This applies to code like:
use constant DEBUG => 1;
DESTROY { return unless DEBUG; ... }
which gets optimised down to:
DESTROY { return; ... }
Adding such a destructor will now have almost no impact on speed in
production.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This also restores the subroutine redefinition warning for newly-cre-
ated XSUBs outside the autouse package. See below.
This commit added the exemption to fix a known bug, that loading a
module and importing from it would cause a redefinition warning if
there were an autouse stub:
perl-5.004_03-1092-g2f34f9d
commit 2f34f9d4825ac9262ece854fc4c50479f4838ff8
Author: Ilya Zakharevich <ilya@math.berkeley.edu>
Date: Mon Mar 2 16:36:02 1998 -0500
Make autouse -w-safe
p4raw-id: //depot/perl@781
The subroutine redefinition warning occurs in three places.
This commit removed the autouse exemption from two
of them. I can’t see how it wasn’t a mistake, as <5104D4DBC598D211B5FE0000F8FE7EB202D49EE9@mbtlipnt02.btlabs.bt.co.uk>
(the apparent source of the patch, makes no mention of it:
perl-5.005_02-2920-ge476b1b
commit e476b1b5c29f354cf8dad61a9fc6d855bdfb5b7d
Author: Gurusamy Sarathy <gsar@cpan.org>
Date: Sun Feb 20 22:58:09 2000 +0000
lexical warnings update, ability to inspect bitmask in calling
scope, among other things (from Paul Marquess)
p4raw-id: //depot/perl@5170
This commit refactored things to remove some compiler warnings, but
in doing so reversed the logic of the condition, causing redefini-
tion warnings for newly-created XSUBs to apply only to subs from the
autouse package:
perl-5.8.0-5131-g66a1b24
commit 66a1b24beb76ea873ad4caa57ee3ab9df945afbf
Author: Andy Lester <andy@petdance.com>
Date: Mon Jun 6 05:11:07 2005 -0500
Random cleanups #47
Message-ID: <20050606151107.GC7022@petdance.com>
p4raw-id: //depot/perl@24735
I’ve basically reinstated the changes in 2f34f9d4, but with tests
this time.
It may not make sense for autouse to be exempt for newATTRSUB and
newXS, but keeping the logic surrounding the warning as close as
possible to being the same could allow future refactorings to
merge them.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
sort $f @list accepts a globref for $f, and probably has since Perl
5.000, even if it was by mistake that it ever worked.
It doesn’t respect get-magic, however:
$ perl -le 'sub s { $b <=> $a }; $f = \*s; print sort $f 1,2,3'
321
$ ./perl -Ilib -le '
sub TIESCALAR{bless[]}
sub FETCH {*s}
sub s { $b <=> $a };
tie $f, "";
$g = \$f;
print sort $g 1,2,3'
Not a subroutine reference at -e line 1.
Interestingly, this commit added support for sort $coderef @foo:
commit 7a4920e67d1e2d67a4397a908141c6608866ebb0
Author: Graham Barr <gbarr@pobox.com>
Date: Fri Nov 27 05:16:50 1998 +0000
integrate change#2246 from mainline, while still allowing
C<sort $globref @foo>
allow C<sort $coderef @foo>
p4raw-link: @2246 on //depot/perl: c6e96bcb406bc8b8d8610606459ff606ad6883aa
p4raw-id: //depot/maint-5.005/perl@2315
p4raw-integrated: from //depot/perl@2314 'merge in' t/op/sort.t
(@1760..)
If I’m reading this code correctly, it did so by nulling out whatever
op used to come after the pushmark (now it is always a null):
$ perl -MO=Concise -e 'sort $fo @fo'8 <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v:{ ->3
7 <@> sort vKS ->8
3 <0> pushmark s ->4
- <1> null K/1 ->5 <--- Lo!
- <1> ex-rv2sv sK/1 ->-
4 <#> gvsv[*fo] s ->5
6 <1> rv2av[t3] lK/1 ->7
5 <#> gv[*fo] s ->6
-e syntax OK
To preserve the globref support (which the nulled op was providing
before), it added it to sv_2cv, which was the wrong place if you ask
me. Now it means that &{\*_} works, in addition to &{*_}. Other
deref ops don’t have this property. Bug? Maybe. But we can just
pretend it’s a feature and live with it.
In any case, extracting the entry of a typeglob without calling get-
magic on it first doesn’t seem right.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When open() has three arguments and the second ends with & the third
argument is treated as a handle.
In some cases get-magic was being skipped; in others, it was being
called three times.
This commit fixes it by modifying sv_2io.
In 5.8.x (before commit 7a5fd60d4), sv_2io did not call get-magic at
all except when croaking ("Bad filehandle: %"SVf). In 5.10.0 (after
commit 7a5fd60d4), it started calling get-magic only if the sv was
neither a glob, a reference, or undef. So it has never been reliable
in its invocation of get-magic.
sv_2io now consistently skips get-magic on the sv passed in directly
to it (open(), the only caller in the core, has already called get-
magic before passing it in). It now calls get-magic on SvRV(sv) if
what is passed in is a reference, so open(fh, ">&", \$tied) will work.
Interestingly, open supports multiple levels of references:
\\\\\\\\\\\\open+f,">&",\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
\\\\\\\\\\\*STDOUT;print{f}"Just another Perl hacker,\n",.\\\\\\\y\\\
|
|
|
|
| |
in apidocs, plus other tweaks
|
|
|
|
| |
Get-magic is only called on ssv. SV_SMAGIC is accepted, too.
|
|
|
|
| |
SV_SMAGIC, not SV_GMAGIC.
|
|
|
|
| |
It respects SV_SMAGIC flag, not SV_GMAGIC (which it ignores).
|
|
|
|
| |
This brings it into conformity with y without the /r.
|
| |
|
|
|
|
|
|
| |
• Typos
• Double space after fullstop, as that is how nroff renders
a fullstop at the end of a line in mid-paragraph.
|
| |
|