Karl Williamson [Thu, 8 Nov 2012 19:02:29 +0000 (12:02 -0700)]
toke.c: Use UTF-8 macros for portability
I noticed this code in toke.c that hand-rolled its own UTF-8 handling,
and is assuming an ASCII platform. There are macros that do the same
thing that this code does, and are portable.
Karl Williamson [Thu, 8 Nov 2012 19:04:34 +0000 (12:04 -0700)]
utf8.h: Add macro that handled malformed 2-byte UTF-8
The macro used traditionally to see if there is a two-byte UTF-8
sequence doesn't make sure that there actually is a second byte
available; it only checks if the first byte indicates that there is.
This adds a macro that is safe in the face of malformed UTF-8.
I inspected the existing calls in the core to the unsafe macro, and I
believe that none of them need to be converted to the safe version.
Karl Williamson [Thu, 8 Nov 2012 18:11:41 +0000 (11:11 -0700)]
util.c: Add some asserts()
These functions improperly have a signed parameter, when the value
should always be at least 0. We have a field report that one of them is
getting called with a negative value. Add asserts to catch this
condition (if compiling assertions is on) earlier.
Karl Williamson [Tue, 30 Oct 2012 16:15:38 +0000 (10:15 -0600)]
utf8.c: Remove redundant unlikely branches
The 2 lines removed in each function provide an early exit if the input
is malformed UTF-8. Other code executed later makes the same test.
But most inputs are going to be well-formed, so the test will almost
always fail, so will slow things up.
Karl Williamson [Fri, 9 Nov 2012 17:18:17 +0000 (10:18 -0700)]
Validate above-Latin1 characters in \N{} aliases
This completes the process of allowing users to define their own aliases
for \N{} in any language they choose. Names have some validation
applied so that they can't, for example, begin with something that is a
digit in some Unicode script. Tests and documentation are included in
this patch. The loop in toke.c that does the validation for
user-supplied translators is revamped, and the messages that are output
when there is an error are fixed to work with UTF-8.
Karl Williamson [Fri, 9 Nov 2012 16:46:37 +0000 (09:46 -0700)]
embed.fnc: Allow toke.c to call core_swash_init()
This internal function is allowed to just a few core functions
by #ifdef's in embed.fnc. Expand the list to include toke.c, as it will
be needed in a future commit.
Karl Williamson [Thu, 1 Nov 2012 18:06:32 +0000 (12:06 -0600)]
toke.c: Fail on malformed UTF-8 in \N{} input
The handler for \N{} can be user-supplied and charnames itself
shouldn't have to worry about malformed input. This changes toke.c to
check for malformed input before calling the \N{} handler.
Karl Williamson [Sun, 28 Oct 2012 16:29:10 +0000 (10:29 -0600)]
toke.c: Remove no-longer needed {...} and outdent correspondingly
No code changes
Brian Fraser [Sun, 28 Oct 2012 16:23:35 +0000 (10:23 -0600)]
toke.c: [RT#73022] Make \N{...} UTF-8 clean.
Karl Williamson [Sun, 28 Oct 2012 15:53:05 +0000 (09:53 -0600)]
toke.c Refactor S_get_and_check_backslash_N_name()
This code was recently factored out into a separate subroutine, and was
originally designed for a non-fatal deprecated warning. This
refactoring just goes immediately to failure when an illegal character
is found.
(It also changes the code to use Perl standard coding practices)
Karl Williamson [Fri, 26 Oct 2012 17:23:51 +0000 (11:23 -0600)]
perldiag: Add entry for unknown charname
Karl Williamson [Fri, 26 Oct 2012 17:06:18 +0000 (11:06 -0600)]
toke.c: Don't validate core charnames output
charnames now refuses to allow invalid aliases to be installed, so we
only need to validate those that come from a custom translator.
Karl Williamson [Fri, 26 Oct 2012 16:48:48 +0000 (10:48 -0600)]
charnames: Don't accept illegal :aliases
Now that improper names for characters are an error, we can forbid them
at definition time. For the time being allow a colon in the check that
continues to be run in toke.c. This will be removed in a future commit.
Karl Williamson [Thu, 8 Nov 2012 18:01:38 +0000 (11:01 -0700)]
regen/mk_PL_charclass.pl: Use mktables table for charname
This commit uses the mktables defined table for whether or not a
character is a legitimate charname continuation. This will allow it to
be kept in sync with other code that needs the definition.
The only change this makes is to delete "colon" from being a legitimate
continuation character. A colon was only accepted because it was used
in the paradigm for like "Greek: Alpha", and is not part of any
actual character name.
Karl Williamson [Thu, 8 Nov 2012 17:59:11 +0000 (10:59 -0700)]
mktables: Create tables for charname beginning and follow-on
mktables is changed to add two new tables, one that matches the first
character in a character names, and one that matches continuation
characters.
Karl Williamson [Fri, 26 Oct 2012 02:12:04 +0000 (20:12 -0600)]
Make \N{alias} deprecations fatal.
Since v5.12, using some non-name like characters, like commas, have
generated a deprecation warning. The required 2 releases have been
made, and they are now being made fatal.
Karl Williamson [Fri, 26 Oct 2012 02:06:17 +0000 (20:06 -0600)]
charnames: Correct pod misstatement
Character names can contain Latin1 currently, not just ASCII.
Karl Williamson [Fri, 26 Oct 2012 01:10:03 +0000 (19:10 -0600)]
toke.c: Extract part of \N{} processing to new function
This is in preparation for making fatal the deprecations that this code
covers.
This code combines the first and final portions of the code that handles
\N{names}, leaving the middle intact. There are no intentional logic
changes. The code is moved and outdented as appropriate for not being
within nested "if's", and the comments are reflowed to fill 79 columns.
One declaration had a const added.
This causes the logic that checks for input name validity to be moved
from after everything is computed to doing it beforehand. Since invalid
names are not currently fatal, there was no problem with checking them
after computing things, but a future commit will make them fatal, so
this saves the work of computing something that is erroneous.
Karl Williamson [Thu, 25 Oct 2012 04:06:48 +0000 (22:06 -0600)]
utf8n_to_uvuni() pod: Add clarifications
Karl Williamson [Thu, 25 Oct 2012 04:05:47 +0000 (22:05 -0600)]
charnames pod: Nits
Karl Williamson [Thu, 25 Oct 2012 03:56:27 +0000 (21:56 -0600)]
charnames.t: Make EXPECTs more robust
We can use OPTIONS regex in test.pl to avoid tieing to a spcific line.
The random option is no longer needed, as the messages that were coming
out in random order have been removed by another commit. The Execution
aborted messages also can be omitted, and the tests pass.
Craig A. Berry [Sun, 11 Nov 2012 14:55:41 +0000 (08:55 -0600)]
Preserve filename case on VMS.
VMS systems of the last decade or so have the ability, when
operating on an ODS-5 volume, to preserve filename case. In order
for CRTL calls to make use of this capability, the feature setting
DECC$EFS_CASE_PRESERVE must be explicitly enabled. We now do that
for Perl at start-up time, which depends on latent support that
has been in the core since 5.10 but not quite working until
recently.
Note that case preservation of command-line arguments is not
included in this feature. That's a different setting and is not
entirely under Perl's control as the command line is parsed by
DCL before the CRTL sees it.
Craig A. Berry [Sun, 11 Nov 2012 14:50:47 +0000 (08:50 -0600)]
Move VMS feature-setting function to an appropriate place.
It was in the middle of the includes at the top of the file. Move
it close to its only use and, more importantly, after the includes,
some of which it now depends on.
Craig A. Berry [Sun, 11 Nov 2012 14:45:28 +0000 (08:45 -0600)]
Set feature logical names in VMS init code.
When setting a CRTL feature, also record the setting in a user-mode
logical name since historically checking the environment is the only
way a Perl program can check a particular setting (otherwise we'd
need the currently vaporware VMS::Feature extension).
Craig A. Berry [Sun, 11 Nov 2012 14:18:56 +0000 (08:18 -0600)]
Normalize VMS case handling in ExtUtils::Manifest.
Both manifind and maniread were not completely matching filesystem
behavior when downcasing filenames.
Craig A. Berry [Sun, 11 Nov 2012 14:09:28 +0000 (08:09 -0600)]
Fix VMS-specific case nit in File::Glob's basic.t.
t/TEST may appear in upper or lower case and with or without a
trailing dot depending on various Unix compatibility settings.
Craig A. Berry [Sun, 11 Nov 2012 14:02:31 +0000 (08:02 -0600)]
Remove an inadvertent case sensitivity from find.t.
The extension of a VMS directory may be presented as .DIR or .dir
depending on various settings and its actual name on disk.
James E Keenan [Sat, 10 Nov 2012 14:05:06 +0000 (09:05 -0500)]
Amplify diagnostic about in-place editing.
An uneditable directory is a "special file" from the point of view of 'perl
-wne'.
For RT #72284. Thanks to frank.wiegand for report.
Chris 'BinGOs' Williams [Sat, 10 Nov 2012 23:57:07 +0000 (23:57 +0000)]
Update IO-Compress to CPAN version 2.057
[DELTA]
2.057 10 November 2012
* IO::Compress::Zip
Allow member name & Zip Comment to be "0"
* IO::Compress::Base::Common
Remove "-r" test - the file open will catch this.
RT# 80855: IO::Compress::Base::Common returns that it cannot read readable files in NFS
* RT# 79820: Install to 'site' instead of 'perl' when perl version is 5.11+
* General Performance improvements.
Chris 'BinGOs' Williams [Sat, 10 Nov 2012 23:53:54 +0000 (23:53 +0000)]
Update Compress-Raw-Bzip2 to CPAN version 2.057
[DELTA]
2.057 10 November 2012
* Compress::Raw::Bzip2 needs to use PERL_NO_GET_CONTEXT
[#80318]
* Install to 'site' instead of 'perl' when perl version is 5.11+
[#79811]
* update to ppport.h that includes SvPV_nomg_nolen
[#78080]
Chris 'BinGOs' Williams [Sat, 10 Nov 2012 23:48:16 +0000 (23:48 +0000)]
Update Compress-Raw-Zlib to CPAN version 2.057
[DELTA]
2.057 10 November 2012
* Compress::Raw::Zlib needs to use PERL_NO_GET_CONTEXT
[#80319]
* Install to 'site' instead of 'perl' when perl version is 5.11+
[#79812]
* update to ppport.h that includes SvPV_nomg_nolen
[#78079]
David Mitchell [Sun, 11 Nov 2012 00:01:21 +0000 (00:01 +0000)]
make MULTICALL safe across cxstack reallocs
[perl #115602]
MUTLICALL sets a local var, cx, to point to the current context stack
frame. When a function is called, the context stack might be realloc()ed,
in which case cx would point to freed memory.
David Mitchell [Sat, 10 Nov 2012 22:39:03 +0000 (22:39 +0000)]
README: add pointer to super-quick patch quide
David Mitchell [Sat, 10 Nov 2012 17:43:53 +0000 (17:43 +0000)]
fix NAME of perl5125delta.pod
Chris 'BinGOs' Williams [Sat, 10 Nov 2012 15:37:00 +0000 (15:37 +0000)]
Module-CoreList updated to 2.77
- Documented decprecated_in() function
- Updated with v5.16.2 data
- Updated with v5.12.5 data
- Updated POD to reflect included perl data
Chris 'BinGOs' Williams [Sat, 10 Nov 2012 15:16:24 +0000 (15:16 +0000)]
The v5.16.2 updates had disappeared (if they were there in the first place) reinstate
Dominic Hargreaves [Sat, 10 Nov 2012 15:16:41 +0000 (15:16 +0000)]
add 5.12.5 to perlhist
Dominic Hargreaves [Sat, 10 Nov 2012 15:13:35 +0000 (15:13 +0000)]
Add the 5.12.5 perldelta
Dominic Hargreaves [Sat, 10 Nov 2012 14:26:22 +0000 (14:26 +0000)]
add 5.12.5 epigraph
David Mitchell [Sat, 10 Nov 2012 11:35:46 +0000 (11:35 +0000)]
[MERGE] add PADRANGE op and $B::overlay
This commit implements three optimisations and one new feature.
The new feature is $B::overlay, which can be set to a hash ref, indexed by
op address, that allows you to override the values returned by the various
B::*OP methods for a particular op. This specifically allows Deparse to be
tricked into seeing a pre-optimisation view of the optree, and so makes
adding new optimisations (like the one in this commit) a lot easier.
As regards optimisations: first, a new save type is added:
SAVEt_CLEARPADRANGE, which is like SAVEt_CLEARSV but specifies a range of
targs to be cleared. The save type, target base and range all fit within a
single integer pushed on the save stack.
Second, a pushmark followed by one or more pad[ahs]v ops (and possibly
some mixed-in null, list and nextstate ops) will sometimes be replaced by
a single padrange op. Like other pad ops, this specifies a targ, but in
addition the bottom 7 bits of op_private indicate a target range.
pp_padrange has two main actions: with OPpLVAL_INTRO, it pushes a
SAVEt_CLEARPADRANGE onto the save stack and turns off SvPADSTALE on all
the lexicals; and in non-void context, it pushes all the lexicals onto the
stack.
Third, for the specific case of the construct my(...) = @_, the
ops to push @_ onto the stack (pushmark/gv[*_]/rv2sv) are skipped,
and the OPf_SPECIAL flag on the padrange op is set: this tells
pp_padrange to push @_ directly.
Note that not sequences of pad ops are consolidated into a single
padrange op; the chief constraints are that:
* they must form a list (i.e. start with pushmark);
* the targs must form a contiguous range;
* the flags of the ops must all be similar; e.g. all INTRO or all not,
all void or all not, etc;
* only a subset of flags are allowed; e.g. we don't optimise with
OPpPAD_STATE or OPpMAYBE_LVSUB present.
For the specific case of void/INTRO, we consolidate across nextstate
boundaries (keeping only the last nextstate); i.e.
my ($a,$b); my @c; my (%d,$e,$f)
becomes a single padrange op. Note that the padrange optimisation is
particularly efficient for the void/INTRO combination: formerly,
my($a,$b,@c,%d); would be compiled as
pushmark; padsv[$a]; padsv[$b]; padav[@c]; padhv[%d]; list; nextstate
which would have the effect of pushing $a, $b onto the stack, then
pushing the (non-existent) elements of @c, then pushing the %d HV; then
pp_list would pop all the elements except the last, %h; finally, nextstate
would pop %h. Instead, padrange skips all the pushing and popping in void
context. Note that this means that there is one user-visible change caused
by this optimisation:
f();
my @a;
sub f { tie @a, ...; push @a, .... }
Here, @a is tied and already has elements by the time the 'my @a' is
executed; formerly, FETCH would be called repeatedly to push the elements
of @a onto the stack, then they would all be popped again at the end of the
'my @a' statement; now FETCH is never called.
The optimisation itself is implemented by converting the initial pushmark
op into a padrange, and updating its op_next. The skipped ops are *not*
cleared; this makes it easier for S_find_uninit_var() and Deparse.pm to do
their stuff. Deparse is implemented by using the new $B::overlay facility
to make the padrange op look like a pushmark op again; the rest of the
Deparse code just sees the original unoptimised optree and so doesn't
require any knowledge of the padrange op.
David Mitchell [Mon, 5 Nov 2012 13:54:51 +0000 (13:54 +0000)]
ext/B/t/OptreeCheck.pm: fix hint stripping
The code that strips hints from a nextstate couldn't handle
the 'next' pointer being '-', e.g. v:>,<,% ->-
David Mitchell [Mon, 5 Nov 2012 13:06:38 +0000 (13:06 +0000)]
fix optree_misc.t test after smoke
Some of the unicode setting in a smoke environment sets the open hints
output on nextstate lines.
David Mitchell [Fri, 2 Nov 2012 16:18:20 +0000 (16:18 +0000)]
Consolidate any single pad ops after a padrange
Given something like
my ($a,$b); my $c; my $d;
then after having detected that we can create a padrange op for $a,$b,
extend it to include $c,$d too.
Together with the previous commit that consolidates adjacent padrange
ops, this means that any contiguous sequence of void 'my' declarations
that starts with a list (i.e. my ($x,..) rather than my $x) will
all be compressed into a single padrange op. For example
my ($a,$b);
my @c;
my %d;
my ($e,@f);
becomes the two ops
padrange[$a;$b;@c;%d;$e;@f]
nextstate
The restriction on the first 'my' being a list is that we only ever
convert pushmarks into padranges, to keep things manageable (both for
compiling and for Deparse). This simply means that
my $x; my ($a,$b); my @c; my %d; my ($e,@f)
becomes
padsv[$x]
nextstate
padrange[$a;$b;@c;%d;$e;@f]
nextstate
David Mitchell [Fri, 2 Nov 2012 14:37:29 +0000 (14:37 +0000)]
Consolidate adjacent padrange ops
In something like
my ($a,$b);
my ($c,$d);
when converting $c,$d into a padrange op, check first whether we're
immediately preceded by a similar padrange (and nextstate) op,
and if so re-use the existing padrange op (by increasing the count).
Also, skip the first nextstate and only use the second nextstate.
So
pushmark;
padsv[$a]; padsv[$b]; list;
nextstate 1;
pushmark;
padsv[$c]; padsv[$c]; list;
nextstate 2;
becomes
padrange[$a,$b]
nextstate 1;
pushmark;
padsv[$c]; padsv[$c]; list;
nextstate 2;
which then becomes
padrange[$a,$b,$c,$d];
nextstate 2;
David Mitchell [Tue, 30 Oct 2012 15:10:06 +0000 (15:10 +0000)]
padrange: handle @_ directly
In a construct like
my ($x,$y) = @_
the pushmark/padsv/padsv is already optimised into a single padrange
op. This commit makes the OPf_SPECIAL flag on the padrange op indicate
that in addition, @_ should be pushed onto the stack, skipping an
additional pushmark/gv[*_]/rv2sv combination.
So in total (including the earlier padrange work), the above construct
goes from being
3 <0> pushmark s
4 <$> gv(*_) s
5 <1> rv2av[t3] lK/1
6 <0> pushmark sRM*/128
7 <0> padsv[$x:1,2] lRM*/LVINTRO
8 <0> padsv[$y:1,2] lRM*/LVINTRO
9 <2> aassign[t4] vKS
to
3 <0> padrange[$x:1,2; $y:1,2] l*/LVINTRO,2 ->4
4 <2> aassign[t4] vKS
David Mitchell [Sun, 28 Oct 2012 12:58:22 +0000 (12:58 +0000)]
reindent block in leave_scope
The previous commit added a loop round a block of code; now increase
the indent of the body of the loop.
David Mitchell [Wed, 17 Oct 2012 18:45:38 +0000 (19:45 +0100)]
add SAVEt_CLEARPADRANGE
Add a new save type that does the equivalent of multiple SAVEt_CLEARSV's
for a given target range. This makes the new padange op more efficient.
David Mitchell [Mon, 24 Sep 2012 12:50:22 +0000 (13:50 +0100)]
add padrange op
This single op can, in some circumstances, replace the sequence of a
pushmark followed by one or more padsv/padav/padhv ops, and possibly
a trailing 'list' op, but only where the targs of the pad ops form
a continuous range.
This is generally more efficient, but is particularly so in the case
of void-context my declarations, such as:
my ($a,@b);
Formerly this would be executed as the following set of ops:
pushmark pushes a new mark
padsv[$a] pushes $a, does a SAVEt_CLEARSV
padav[@b] pushes all the flattened elements (i.e. none) of @a,
does a SAVEt_CLEARSV
list pops the mark, and pops all stack elements except the last
nextstate pops the remaining stack element
It's now:
padrange[$a..@b] does two SAVEt_CLEARSV's
nextstate nothing needing doing to the stack
Note that in the case above, this commit changes user-visible behaviour in
pathological cases; in particular, it has always been possible to modify a
lexical var *before* the my is executed, using goto or closure tricks.
So in principle someone could tie an array, then could notice that FETCH
is no longer being called, e.g.
f();
my ($s, @a); # this no longer triggers two FETCHES
sub f {
tie @a, ...;
push @a, 1,2;
}
But I think we can live with that.
Note also that having a padrange operator will allow us shortly to have
a corresponding SAVEt_CLEARPADRANGE save type, that will replace multiple
individual SAVEt_CLEARSV's.
David Mitchell [Tue, 25 Sep 2012 11:47:51 +0000 (12:47 +0100)]
pad_free(): don't clear SVs_PADSTALE
pad_free() clears the SVs_PADTMP bit. Since that bit is now shared
with SVs_PADSTALE, that gets cleared on state vars. It didn't matter up
till now, but the next commit will start optimising away pad ops, and
op_null() will call pad_free() which would clear the SVs_PADSTALE bit.
So only clear SVs_PADTMP/SVs_PADSTALE for non-lexical var ops.
David Mitchell [Tue, 23 Oct 2012 20:39:10 +0000 (21:39 +0100)]
add $B::overlay feature
This allows you to alter the read-only "view" of an optree, by making
particular B::*OP methods on particular op nodes return customised values.
Intended to be used by B::Deparse to "undo" optimisations, thus making it
easier to add new optree optimisations without breaking Deparse.
Chris 'BinGOs' Williams [Sat, 10 Nov 2012 12:31:46 +0000 (12:31 +0000)]
Update CGI to CPAN version 3.62
[DELTA]
Version 3.62, Nov 9th, 2012
[INTERNALS]
- Changed how the deprecated endform function was defined for compatibilty
with the development version of Perl.
- Fix failures in t/tmpdir.t when run as root
https://github.com/markstos/CGI.pm/issues/22, RT#80659)
- Made it possible to force a sorted order for things like hash
attributes so that tests are not dependent on a particular hash
ordering. This will be required in modern perls which will
change the ordering per process. (Yves, RT#80659)
Chris 'BinGOs' Williams [Sat, 10 Nov 2012 12:29:21 +0000 (12:29 +0000)]
Update Term-UI to CPAN version 0.32
[DELTA]
Changes for 0.32 Sat Nov 10 11:00:31 GMT 2012
=====================================================
* Add a delimiter to a prompt that doesn't have a default
(Tommy Stanton)
Steve Hay [Fri, 9 Nov 2012 15:04:35 +0000 (15:04 +0000)]
Restore non-DEBUGGING build on Win32, broken in
28e70dfacc
Steve Hay [Fri, 9 Nov 2012 08:39:36 +0000 (08:39 +0000)]
Restore DEBUGGING build with USE_ITHREADS on Win32, broken in
9399a70c62
Shlomi Fish [Fri, 9 Nov 2012 04:15:14 +0000 (06:15 +0200)]
Fix the phrasing of the previous patch.
Thanks to Father C, and David Golden for their input. Removed what was
said about the -w being deprecated.
Shlomi Fish [Thu, 8 Nov 2012 09:38:59 +0000 (11:38 +0200)]
Replace mentions of the "-w" flag in perl.pod.
Replace these mentions of the deprecated -w flag (which is applied
globally) with mentions of use warnings (and possibly also use strict).
Thanks to tm604 on Freenode's #perl for noticing that.
Daniel Dragan [Wed, 7 Nov 2012 23:03:10 +0000 (18:03 -0500)]
refactor gv.c:Perl_newGP
This commit fixes a scenario was strlen("") was called unnecessarily.
Replaced with 0. Also various func calls were rearranged for more calls
to happen near the beginning to maximize use of volatile registers
towards the end for PERL_HASH. PERL_HASH was moved to be closer to the
first usage of var hash. Setting gp_line to 0 was removed since the block
was just calloced and is already 0. Filling of gp.gp_egv was moved early
so var gv on C stack might get reused by compiler optimizer to store
something else to decrease the stack frame size of Perl_newGP.
PERL_ARGS_ASSERT_NEWGP was moved to be outside of an ifdef.
Also see commits
128165928a7 ,
19bad6733a8 ,
1df5f7c1950 ,
f4890806d3 .
Father Chrysostomos [Fri, 9 Nov 2012 02:14:06 +0000 (18:14 -0800)]
To-do test for eval "END OF TERMS" leaking
I found this memory leak by evaluating lines of the Copying file as
Perl code. :-)
The parser requires yylex to return exactly one token with each call.
Sometimes yylex needs to record a few tokens ahead of time, so its
puts them in its forced token stack. The next call to yylex then pops
the pending token off that stack.
Ops belong to their subroutines. If the subroutine is freed before
its root is attached, all the ops created when PL_compcv pointed
to that sub are freed as well. To avoid crashes, the ops on the
savestack and the forced token stack are specially marked so they are
not freed when the sub is freed.
When it comes to evaluating "END OF TERMS AND CONDITIONS", the END
token causes a subroutine to be created and placed in PL_compcv. The
OF token is treated by the lexer as a method call on the TERMS pack-
age. The TERMS token is placed in the forced token stack as an sv in
an op for a WORD token, and a METHOD token for OF is returned. As
soon as the parser sees the OF, it generates an error, which results
in LEAVE_SCOPE being called, which frees the subroutine for END while
TERMS is still on the forced token stack. So the subroutine’s op
cleanup skips that op. Then the parser calls back into the lexer,
which returns the TERMS token from the forced token stack. Since
there has been an error, the parser discards that token, so the op
is never freed. The forced token stack cleanup that happens in
parser_free does not catch this, as the token is no longer on
that stack.
I have not yet determined how to fix this problem.
Father Chrysostomos [Wed, 7 Nov 2012 07:59:51 +0000 (23:59 -0800)]
Another regexp charclass leak
Compiling a negated character class can cause internal temporary sca-
lars to leak, as of v5.17.1-252-gea364ff.
(I don’t understand how v5.17.1-252-gea364ff caused it, but bisect
points to it.)
Father Chrysostomos [Wed, 7 Nov 2012 07:56:56 +0000 (23:56 -0800)]
leakfinder.pl: Yet mair exceptions
Father Chrysostomos [Wed, 7 Nov 2012 00:42:34 +0000 (16:42 -0800)]
regcomp.c: Typo
Daniel Dragan [Mon, 5 Nov 2012 07:19:29 +0000 (02:19 -0500)]
remove various redundant dTHXes
Remove either unused dTHXes, or remove dTHXes where a nocontext func can
be used instead. Smaller/faster machine code is the result.
Daniel Dragan [Sat, 3 Nov 2012 18:53:55 +0000 (14:53 -0400)]
remove unused dTHXes in /win32/*
Remove dTHXes in win32 perl funcs where they were not used, or could be
replaced with nocontext croaks/warns. Since Perl_get_context is a function
it is not optimized away by the compiler.
Daniel Dragan [Wed, 31 Oct 2012 06:13:42 +0000 (02:13 -0400)]
create aTHXa, some unused dTHXs removed in /win32/*
dTHXes that were unused, or because Newx/Safefree were the only things
called were removed. In some places the dTHX turned into dTHXa and aTHXa
so the context is not fetched until it is actually used
(locality/frees a C stack slot or frees a non-volatile register). Also see
http://www.nntp.perl.org/group/perl.perl5.porters/2012/10/msg194414.html
and http://www.nntp.perl.org/group/perl.perl5.porters/2012/10/msg194861.html
Daniel Dragan [Sun, 28 Oct 2012 02:25:47 +0000 (22:25 -0400)]
"func not implemented" croaks optimizations in /win32/*
This commit removes a number of "* not implemented" strings from the image.
A win32_croak_not_implemented wrapper is created to reduce machine code
by not putting the format string on the C stack many times. embed.fnc was
used to declare win32_croak_not_implemented for proper cross compiler
support of noreturn (noreturn on GCC and VC ok). Tailcalling and noreturn
optimizations of the C compiler are heavily used in this commit.
David Golden [Thu, 8 Nov 2012 19:24:20 +0000 (14:24 -0500)]
perlpolicy: remove 5.12 references from maint cherry pick policy
Yves Orton [Thu, 8 Nov 2012 07:12:53 +0000 (08:12 +0100)]
Sync version of autodie in Maintainers.pl with CPAN
Yves Orton [Mon, 27 Aug 2012 06:54:50 +0000 (08:54 +0200)]
fix a hash key order dependency in cpan/autodie/t/hints_pod_examples.t
At the same time make part of the internals deterministic Just In Case.
Version bump on autodie to 2.13 as well.
Jesse Luehrs [Wed, 7 Nov 2012 17:45:16 +0000 (11:45 -0600)]
limit number of args before formatting
this makes a difference when the number of args is quite large
Jesse Luehrs [Thu, 29 Mar 2012 02:44:41 +0000 (21:44 -0500)]
fix Carp stacktraces after deleting a stash
When a stash is deleted, caller() will return undef in the package slot
for any stack level for which the deleted stash was the current package.
This made Carp confused in some cases, so fix that.
Father Chrysostomos [Tue, 6 Nov 2012 20:32:47 +0000 (12:32 -0800)]
Remove x bit from MANIFEST
Jerry D. Hedden [Wed, 24 Oct 2012 02:48:50 +0000 (22:48 -0400)]
Upgrade to Thread::Queue 3.01
Father Chrysostomos [Tue, 6 Nov 2012 18:02:21 +0000 (10:02 -0800)]
svleak.t: Fix a mad failure
Father Chrysostomos [Tue, 6 Nov 2012 18:00:12 +0000 (10:00 -0800)]
Stop eval "qq'\$\0foo'" from leaking
If the dollar sign in a double-quoted string is followed by a null,
then scan_ident gets confused, as it uses the nullness to keep track
of whether it has found an identifier. In this case it treats $\0 as
a punctuation variable but then loses track of that fact and thinks it
has found the end of the string.
It’s complicated, but the end result is that the sequence of tokens
emitted for eval "qq'$\0foo'" would be the following:
stringify ( $ . "foo" )
instead of this:
stringify ( $ <ident> . "foo" )
But the missing identifier after the dollar sign results in a syn-
tax error that prevents yylex from having a chance to emit the
"foo", which by that time it has put on the forced token stack.
There are cases in which the CV that owns the ops on the forced token
stack can be freed while the ops are still on that stack and will
still be fed to the parser, so we treat the forced token stack like
the savestack, and do not allow ops thereon to be freed when their CV
is freed, to avoid feeding freed ops to the parser.
In this case, it means that the ops on the stack are never freed,
resulting in a memory leak.
Whether scan_ident needs to be fixed (or ‘fixed’) I don’t know. I do
know that when the parser is freed any remaining forced tokens should
also be freed. Even if this leak could be fixed some other way, it
would still be a good idea for parser_free to check for forced tokens
that need to be cleaned up.
Father Chrysostomos [Mon, 5 Nov 2012 21:10:11 +0000 (13:10 -0800)]
leakfinder.pl: Clean up exceptions
Remove two (exit and END) that were from preliminary versions of
the script.
Skip all lines beginning with push and unshift.
Remove leading whitespace when looking up exceptions.
Father Chrysostomos [Mon, 5 Nov 2012 21:07:47 +0000 (13:07 -0800)]
leakfinder.pl: Another exception
Craig A. Berry [Tue, 6 Nov 2012 13:02:51 +0000 (07:02 -0600)]
Skip non-functional glob test on VMS.
Chris 'BinGOs' Williams [Tue, 6 Nov 2012 13:06:27 +0000 (13:06 +0000)]
Sync the version of Module::Pluggable in Maintainers.pl with CPAN
Yves Orton [Tue, 6 Nov 2012 08:26:35 +0000 (09:26 +0100)]
upgrade Module::Pluggable to 4.5 (test changes only)
note there is an untrue comment next to VERSION line in Pluggable.pm, 4.5 is also on CPAN.
Also note this patch keeps the old Makefile.PL based make process intact.
David Mitchell [Mon, 5 Nov 2012 14:57:28 +0000 (14:57 +0000)]
fix NO_TAINT_SUPPORT on g++
A '&' got lost in the conversion
Father Chrysostomos [Mon, 5 Nov 2012 14:21:35 +0000 (06:21 -0800)]
perl.h: s/non-existant/nonexistent/
Paul Johnson [Mon, 5 Nov 2012 13:39:45 +0000 (14:39 +0100)]
Lose the loose. Fix documentation typo.
Steffen Mueller [Mon, 5 Nov 2012 07:06:43 +0000 (08:06 +0100)]
More violent warning about using NO_TAINT_SUPPORT
I failed to update the commit message of the previous commit (sorry!).
The code is in a much better shape than the message claims and Configure
support, for example, won't be added at all to require more
determination from users. PL_taint_warn has since received the same
treatment. To wit:
# define TAINT_WARN_get (PL_taint_warn)
# define TAINT_WARN_set(s) (PL_taint_warn = (s))
Steffen Mueller [Tue, 9 Oct 2012 09:19:37 +0000 (11:19 +0200)]
Add C define to remove taint support from perl
By defining NO_TAINT_SUPPORT, all the various checks that perl does for
tainting become no-ops. It's not an entirely complete change: it doesn't
attempt to remove the taint-related interpreter variables, but instead
virtually eliminates access to it.
Why, you ask? Because it appears to speed up perl's run-time
significantly by avoiding various "are we running under taint" checks
and the like.
This change is not in a state to go into blead yet. The actual way I
implemented it might raise some (valid) objections. Basically, I
replaced all uses of the global taint variables (but not PL_taint_warn!)
with an extra layer of get/set macros (TAINT_get/TAINTING_get).
Furthermore, the change is not complete:
- PL_taint_warn would likely deserve the same treatment.
- Obviously, tests fail. We have tests for -t/-T
- Right now, I added a Perl warn() on startup when -t/-T are detected
but the perl was not compiled support it. It might be argued that it
should be silently ignored! Needs some thinking.
- Code quality concerns - needs review.
- Configure support required.
- Needs thinking: How does this tie in with CPAN XS modules that use
PL_taint and friends? It's easy to backport the new macros via PPPort,
but that doesn't magically change all code out there. Might be
harmless, though, because whenever you're running under
NO_TAINT_SUPPORT, any check of PL_taint/etc is going to come up false.
Thus, the only CPAN code that SHOULD be adversely affected is code
that changes taint state.
Father Chrysostomos [Mon, 5 Nov 2012 04:18:51 +0000 (20:18 -0800)]
Stop the glob operator from leaking GVs
It was adding GVs to the symbol table (via newGVgen), so they
would never be freed, even after the op was freed, unless done so
explicitly.
There is no reason for these GVs to be exposed.
Father Chrysostomos [Mon, 5 Nov 2012 02:33:52 +0000 (18:33 -0800)]
leakfinder.pl: Mair exceptions
Father Chrysostomos [Mon, 5 Nov 2012 02:26:12 +0000 (18:26 -0800)]
leakfinder.pl: Show file names
It can take a *very* long time to run, so give some indication
that it is actually doing something.
Father Chrysostomos [Mon, 5 Nov 2012 02:21:34 +0000 (18:21 -0800)]
op.c:opslab_force_free: Make paranoid code reflect reality
When opslab_force_free is called, the CV still has a reference count
on the slab. In fact, we don’t even bother lowering it if all goes
well, but simply free the slab with the reference count set to 1.
So the paranoid code that increments the reference count before free-
ing an op is not necessary. Also, the shortcut out of the loop
was never triggered, as it was checking for a reference count of 0,
rather than 1.
Father Chrysostomos [Mon, 5 Nov 2012 01:44:06 +0000 (17:44 -0800)]
op.c: Stop SAVEFREEOP from leaking slabs
When a CV is freed prematurely, it cleans up its op slab. But
SAVEFREEOP may cause the savestack to point to an op in that slab
after the CV has been freed, so SAVEFREEOP is allowed to coun-
termand the freeing of the slab. Every op that is not on the
savestack is freed.
The reference count of the slab was being left off by one. The result
was that when the stack unwinding freed the op, it would leave the
slab behind and leak it.
Father Chrysostomos [Sun, 4 Nov 2012 22:57:49 +0000 (14:57 -0800)]
Stop %! after syntax error from leaking the module name
Father Chrysostomos [Sun, 4 Nov 2012 22:39:07 +0000 (14:39 -0800)]
gv.c:S_require_tie_mod: remove SPAGAIN
We are not using SP after this point.
Father Chrysostomos [Sun, 4 Nov 2012 19:03:17 +0000 (11:03 -0800)]
Don’t leak BEGIN blocks after syntax errors
Father Chrysostomos [Sun, 4 Nov 2012 07:38:45 +0000 (00:38 -0700)]
leakfinder.pl: Use DD for output
This solves the problem of binary code being dumped into the
terminal.
Father Chrysostomos [Sun, 4 Nov 2012 07:03:43 +0000 (00:03 -0700)]
Don’t leak pattern buffer when invalid flags croak
Normally if there is a syntax error yyerror just records it and pars-
ing continues anyway. If there are too many syntax errors, it croaks.
It just happened that if it croaked when encountering invalid flags
for quote-like operators it would leak the buffer containing the pat-
tern (and the substitution for s///).
Since those are stored in the parser struct and are set to null when-
ever something else takes ownership of the SV, these struct members
will only ever be non-null in parser_free when they have leaked. So
we can free them there. (I.e., these slots have always been refer-
ence-counted, so treat them that way.)
Father Chrysostomos [Sun, 4 Nov 2012 01:53:52 +0000 (18:53 -0700)]
svleak.t: Enable syntax error tests under -Dmad
Also use the fairly new eleak for brevity’s sake (and also because it
knows about the existing mad leak for string evals).
Father Chrysostomos [Sun, 4 Nov 2012 00:54:48 +0000 (17:54 -0700)]
Use shared memory for sv_debug_file
With -DDEBUGGING -Accflags=-DDEBUG_LEAKING_SCALARS -Duseithreads:
use threads;
use threads::shared;
my @shared_ary :shared;
$shared_ary[0] = &threads::shared::share({});
@shared_ary = ();
__END__
panic: free from wrong pool, 881c00!=800000.
Scalars leaked: 1
threads::shared has to juggle multiple interpreters. Sometimes the
interpreter it is calling into (and passing as the first argument
via pTHX) is not actually the current thread as far as the OS is
concerned.
Perl_safesysfree in util.c does not take a pTHX parameter, so it
fetches the current interpreter from the data associated with the cur-
rent thread.
The result is that PERL_TRACK_MEMPOOL complains that the file name
associated with an SV under DEBUG_LEAKING_SCALARS is being freed from
the wrong interpreter.
Using shared memory for the file name solves the issue.
Father Chrysostomos [Sat, 3 Nov 2012 18:33:56 +0000 (11:33 -0700)]
Stop require nonexistent::module from leaking
This leak was caused by v5.17.4-125-gf7ee53b.
Father Chrysostomos [Sat, 3 Nov 2012 16:28:54 +0000 (09:28 -0700)]
svleak.t: re-evals leak under mad
Father Chrysostomos [Sat, 3 Nov 2012 18:26:52 +0000 (11:26 -0700)]
Fix invalid token warning with PERL_XMLDUMP and label
Under mad builds, commit 5db1eb8 caused this warning:
$ PERL_XMLDUMP=/dev/null ./perl -Ilib -e 'foo:'
Invalid TOKEN object ignored at -e line 1.
Since I don’t understand the mad code so well, the easiest fix is to
revert back to using a PV, as we did before 5db1eb8. To record the
utf8ness, we sneak it behind the trailing null.
Father Chrysostomos [Sat, 3 Nov 2012 13:50:04 +0000 (06:50 -0700)]
Stop statement labels from leaking
They have leaked since v5.15.9-35-g5db1eb8 (which probably broke mad
dumping of labels; to be addressed in the next commit).