This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
11 years agoadd 5.12.5 to perlhist
Dominic Hargreaves [Sat, 10 Nov 2012 15:16:41 +0000 (15:16 +0000)]
add 5.12.5 to perlhist

11 years agoAdd the 5.12.5 perldelta
Dominic Hargreaves [Sat, 10 Nov 2012 15:13:35 +0000 (15:13 +0000)]
Add the 5.12.5 perldelta

11 years agoadd 5.12.5 epigraph
Dominic Hargreaves [Sat, 10 Nov 2012 14:26:22 +0000 (14:26 +0000)]
add 5.12.5 epigraph

11 years ago[MERGE] add PADRANGE op and $B::overlay
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.

11 years agoext/B/t/OptreeCheck.pm: fix hint stripping
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:>,<,% ->-

11 years agofix optree_misc.t test after smoke
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.

11 years agoConsolidate any single pad ops after a padrange
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

11 years agoConsolidate adjacent padrange ops
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;

11 years agopadrange: handle @_ directly
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

11 years agoreindent block in leave_scope
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.

11 years agoadd SAVEt_CLEARPADRANGE
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.

11 years agoadd padrange op
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.

11 years agopad_free(): don't clear SVs_PADSTALE
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.

11 years agoadd $B::overlay feature
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.

11 years agoUpdate CGI to CPAN version 3.62
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)

11 years agoUpdate Term-UI to CPAN version 0.32
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)

11 years agoRestore non-DEBUGGING build on Win32, broken in 28e70dfacc
Steve Hay [Fri, 9 Nov 2012 15:04:35 +0000 (15:04 +0000)]
Restore non-DEBUGGING build on Win32, broken in 28e70dfacc

11 years agoRestore DEBUGGING build with USE_ITHREADS on Win32, broken in 9399a70c62
Steve Hay [Fri, 9 Nov 2012 08:39:36 +0000 (08:39 +0000)]
Restore DEBUGGING build with USE_ITHREADS on Win32, broken in 9399a70c62

11 years agoFix the phrasing of the previous patch.
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.

11 years agoReplace mentions of the "-w" flag in perl.pod.
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.

11 years agorefactor gv.c:Perl_newGP
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 .

11 years agoTo-do test for eval "END OF TERMS" leaking
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.

11 years agoAnother regexp charclass leak
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.)

11 years agoleakfinder.pl: Yet mair exceptions
Father Chrysostomos [Wed, 7 Nov 2012 07:56:56 +0000 (23:56 -0800)]
leakfinder.pl: Yet mair exceptions

11 years agoregcomp.c: Typo
Father Chrysostomos [Wed, 7 Nov 2012 00:42:34 +0000 (16:42 -0800)]
regcomp.c: Typo

11 years agoremove various redundant dTHXes
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.

11 years agoremove unused dTHXes in /win32/*
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.

11 years agocreate aTHXa, some unused dTHXs removed in /win32/*
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

11 years ago"func not implemented" croaks optimizations in /win32/*
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.

11 years agoperlpolicy: remove 5.12 references from maint cherry pick policy
David Golden [Thu, 8 Nov 2012 19:24:20 +0000 (14:24 -0500)]
perlpolicy: remove 5.12 references from maint cherry pick policy

11 years agoSync version of autodie in Maintainers.pl with CPAN
Yves Orton [Thu, 8 Nov 2012 07:12:53 +0000 (08:12 +0100)]
Sync version of autodie in Maintainers.pl with CPAN

11 years agofix a hash key order dependency in cpan/autodie/t/hints_pod_examples.t
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.

11 years agolimit number of args before formatting
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

11 years agofix Carp stacktraces after deleting a stash
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.

11 years agoRemove x bit from MANIFEST
Father Chrysostomos [Tue, 6 Nov 2012 20:32:47 +0000 (12:32 -0800)]
Remove x bit from MANIFEST

11 years agoUpgrade to Thread::Queue 3.01
Jerry D. Hedden [Wed, 24 Oct 2012 02:48:50 +0000 (22:48 -0400)]
Upgrade to Thread::Queue 3.01

11 years agosvleak.t: Fix a mad failure
Father Chrysostomos [Tue, 6 Nov 2012 18:02:21 +0000 (10:02 -0800)]
svleak.t: Fix a mad failure

11 years agoStop eval "qq'\$\0foo'" from leaking
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.

11 years agoleakfinder.pl: Clean up exceptions
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.

11 years agoleakfinder.pl: Another exception
Father Chrysostomos [Mon, 5 Nov 2012 21:07:47 +0000 (13:07 -0800)]
leakfinder.pl: Another exception

11 years agoSkip non-functional glob test on VMS.
Craig A. Berry [Tue, 6 Nov 2012 13:02:51 +0000 (07:02 -0600)]
Skip non-functional glob test on VMS.

11 years agoSync the version of Module::Pluggable in Maintainers.pl with CPAN
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

11 years agoupgrade Module::Pluggable to 4.5 (test changes only)
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.

11 years agofix NO_TAINT_SUPPORT on g++
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

11 years agoperl.h: s/non-existant/nonexistent/
Father Chrysostomos [Mon, 5 Nov 2012 14:21:35 +0000 (06:21 -0800)]
perl.h: s/non-existant/nonexistent/

11 years agoLose the loose. Fix documentation typo.
Paul Johnson [Mon, 5 Nov 2012 13:39:45 +0000 (14:39 +0100)]
Lose the loose. Fix documentation typo.

11 years agoMore violent warning about using NO_TAINT_SUPPORT
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))

11 years agoAdd C define to remove taint support from perl origin/smueller/no_taint3
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.

11 years agoStop the glob operator from leaking GVs
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.

11 years agoleakfinder.pl: Mair exceptions
Father Chrysostomos [Mon, 5 Nov 2012 02:33:52 +0000 (18:33 -0800)]
leakfinder.pl: Mair exceptions

11 years agoleakfinder.pl: Show file names
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.

11 years agoop.c:opslab_force_free: Make paranoid code reflect reality
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.

11 years agoop.c: Stop SAVEFREEOP from leaking slabs
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.

11 years agoStop %! after syntax error from leaking the module name
Father Chrysostomos [Sun, 4 Nov 2012 22:57:49 +0000 (14:57 -0800)]
Stop %! after syntax error from leaking the module name

11 years agogv.c:S_require_tie_mod: remove SPAGAIN
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.

11 years agoDon’t leak BEGIN blocks after syntax errors
Father Chrysostomos [Sun, 4 Nov 2012 19:03:17 +0000 (11:03 -0800)]
Don’t leak BEGIN blocks after syntax errors

11 years agoleakfinder.pl: Use DD for output
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.

11 years agoDon’t leak pattern buffer when invalid flags croak
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.)

11 years agosvleak.t: Enable syntax error tests under -Dmad
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).

11 years agoUse shared memory for sv_debug_file
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.

11 years agoStop require nonexistent::module from leaking
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.

11 years agosvleak.t: re-evals leak under mad
Father Chrysostomos [Sat, 3 Nov 2012 16:28:54 +0000 (09:28 -0700)]
svleak.t: re-evals leak under mad

11 years agoFix invalid token warning with PERL_XMLDUMP and label
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.

11 years agoStop statement labels from leaking
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).

11 years agoStop char classes from leaking
Father Chrysostomos [Sat, 3 Nov 2012 13:01:19 +0000 (06:01 -0700)]
Stop char classes from leaking

Since 5.10.0, this script has leaked:

$ perl -e 'warn$$; while(1){eval "/[:]/"}'

What exactly has leaked has changed over time.  In bleadperl
it is this:

SV = PV(0x8033c8) at 0x836170
  REFCNT = 1
  FLAGS = ()
  PV = 0x31c0b0 "\2\0\0\0\377\377\377\377\0\0\0\0\f\fS\21\1\0\0\0:\0\0\0;\0\0\0"\0
  CUR = 28
  LEN = 32

This only happens when the character class has only one character in
it, the same character repeated ([aa]), or a multicharacter fold.

A character class is usually compiled as an ANYOF node, but [A] is
optimised down to just A (and EXACT) and /[\xdf]/i is rewritten into a
more complex expression.

When the ANYOF node is abandoned, we need to free any temporary SVs
created in the mean time.  A few of them were leaking.

11 years agoleakfinder.pl
Father Chrysostomos [Sat, 3 Nov 2012 00:43:47 +0000 (17:43 -0700)]
leakfinder.pl

I wrote this to look for memory leaks.  Since it could be useful to
re-run it at some future time, I might as well put it somewhere where
it will not get lost.

It still needs a bit of work.  Currently, evaluating chunks of binary
code can cause memory leaks.  In those cases the binary code is dumped
straight to the terminal, which is not helpful.

11 years agosimplify GIMME_V
David Mitchell [Sun, 4 Nov 2012 18:23:25 +0000 (18:23 +0000)]
simplify GIMME_V

Since OPf_WANT_VOID == G_VOID etc, we can substantially simplify
the OP_GIMME macro (which is what implements GIMME_V).
This saves 588 bytes in the perl executable on my -O2 system.

11 years agoUpdate CGI to CPAN version 3.61
Chris 'BinGOs' Williams [Sun, 4 Nov 2012 13:05:12 +0000 (13:05 +0000)]
Update CGI to CPAN version 3.61

  [DELTA]

  Version 3.61 Nov 2nd, 2012

    (No code changes)

    [INTERNALS]
      - formatting of CGI::Carp documentation was improved. Thanks to benkasminbullock.
      - un-TODO some tests in t/tmpdir.t that were passing in most cases.
      More on this:
        https://github.com/markstos/CGI.pm/issues/19#
        https://github.com/markstos/CGI.pm/commit/cc73dc9807b0fabb56b3cdf1a9726588b2eda0f7

11 years agoUpdate Unicode-Normalize to CPAN version 1.16
Chris 'BinGOs' Williams [Sun, 4 Nov 2012 13:01:02 +0000 (13:01 +0000)]
Update Unicode-Normalize to CPAN version 1.16

  [DELTA]

  1.16  Sun Nov  4 17:23:03 2012
    - XSUB: use PERL_NO_GET_CONTEXT (see perlguts)
      (see [rt.cpan.org #80312])

11 years agoUpdate Unicode-Collate to CPAN version 0.91
Chris 'BinGOs' Williams [Sun, 4 Nov 2012 12:59:11 +0000 (12:59 +0000)]
Update Unicode-Collate to CPAN version 0.91

  [DELTA]

  0.91  Sun Nov  4 17:00:20 2012
    - XSUB: use PERL_NO_GET_CONTEXT (see perlguts)
      (see [rt.cpan.org #80313])

11 years agoUpdate Digest-SHA to CPAN version 5.73
Chris 'BinGOs' Williams [Sun, 4 Nov 2012 12:56:46 +0000 (12:56 +0000)]
Update Digest-SHA to CPAN version 5.73

  [DELTA]

  5.73  Wed Oct 31 04:32:44 MST 2012
    - provided workaround for DEC compiler bug (ref. Makefile.PL)

11 years agoSync Module-CoreList version in Maintainers.pl with CPAN
Chris 'BinGOs' Williams [Sun, 4 Nov 2012 12:52:43 +0000 (12:52 +0000)]
Sync Module-CoreList version in Maintainers.pl with CPAN

11 years agofix an epigraph typo
Ricardo Signes [Sat, 3 Nov 2012 23:14:26 +0000 (19:14 -0400)]
fix an epigraph typo

reported by Vadim Konovalov; thanks!

11 years agoRemove thread context from Perl_vmssetuserlnm.
Craig A. Berry [Sat, 3 Nov 2012 13:11:44 +0000 (08:11 -0500)]
Remove thread context from Perl_vmssetuserlnm.

This routine by its very nature applies to the whole process so
there is no way it can make use of a thread context, and it may need
to be called from places where there is no thread context, such
as very early in start-up.

It's not documented, was never intended to be part of the API, was
only made global so it could be called from doio.c, and no uses of
it turn up in a CPAN grep, so the change should be safe.

11 years agoIncrease $Module::CoreList::VERSION to 2.76
Father Chrysostomos [Fri, 2 Nov 2012 21:48:48 +0000 (14:48 -0700)]
Increase $Module::CoreList::VERSION to 2.76

11 years agoprint deprecation information in corelist
Alexandr Ciornii [Wed, 31 Oct 2012 10:31:47 +0000 (12:31 +0200)]
print deprecation information in corelist

11 years agosvleak.t: Suppress warning
Father Chrysostomos [Fri, 2 Nov 2012 19:36:23 +0000 (12:36 -0700)]
svleak.t: Suppress warning

11 years agoStop string eval from leaking ops
Father Chrysostomos [Fri, 2 Nov 2012 19:35:25 +0000 (12:35 -0700)]
Stop string eval from leaking ops

This was leaking:

$ ./miniperl  -Xe 'warn $$; while(1){eval "ok 8"};'
1915 at -e line 1.
^C

This was not:

$ ./miniperl  -Xe 'warn $$; while(1){eval "sub {ok 8}"};'
1916 at -e line 1.
^C

The sub is successfully taking care of its ops when it is freed.  The
eval is not.

I made the mistake of having the CV relinquish ownership of the op
slab after an eval syntax error.  That’s precisely the situation in
which the ops are likely to leak, and for which the slab allocator was
designed.  Duh.

11 years agoDon’t leak when printf causes wide warnings
Father Chrysostomos [Fri, 2 Nov 2012 13:17:36 +0000 (06:17 -0700)]
Don’t leak when printf causes wide warnings

11 years agoDon’t leak when printfing to bad handle under fatal warnings
Father Chrysostomos [Fri, 2 Nov 2012 13:12:27 +0000 (06:12 -0700)]
Don’t leak when printfing to bad handle under fatal warnings

11 years agoconcat2.t: Under miniperl only skip one test
Father Chrysostomos [Fri, 2 Nov 2012 12:59:31 +0000 (05:59 -0700)]
concat2.t: Under miniperl only skip one test

11 years agoFix $byte_overload .= $utf8 regression
Father Chrysostomos [Fri, 2 Nov 2012 12:48:34 +0000 (05:48 -0700)]
Fix $byte_overload .= $utf8 regression

This is a regression from 5.12.

This was probably broken by commit c5aa287237.

#!perl -lCS
{ package o; use overload '""' => sub { $_[0][0] } }

$x = bless[chr 256],o::;
"$x";
$x->[0] = "\xff";
$x.= chr 257;
$x.= chr 257;

use Devel::Peek;
Dump $x;
print $x;
__END__

Output under 5.12.4:

SV = PVIV(0x820604) at 0x825820
  REFCNT = 1
  FLAGS = (POK,pPOK,UTF8)
  IV = 0
  PV = 0x2139d0 "\303\277\304\201\304\201"\0 [UTF8 "\x{ff}\x{101}\x{101}"]
  CUR = 6
  LEN = 16
ÿāā

Output under 5.14.0:

SV = PVIV(0x820604) at 0x826490
  REFCNT = 1
  FLAGS = (POK,pPOK,UTF8)
  IV = 0
  PV = 0x316230 "\303\277\303\204\302\201\304\201"\0 [UTF8 "\x{ff}\x{c4}\x{81}\x{101}"]
  CUR = 8
  LEN = 16
ÿÄ\81ā

The UTF8 flag is only meaningful right after stringification.

If the $byte_overload scalar happens to have the flag on from last
time, but string overloading will turn the flag off, then pp_concat
gets confused as to whether it is dealing with bytes or utf8.  It
sees both sides as having the same utf8ness, so it concatenates,
which stringifies the lhs and turns off the flag.  The utf8 sequences
appended end up with no utf8 flag associated with them, the observable
effect being that the rhs is encoded as utf8.

If it weren’t for encoding.pm, we could use sv_catpvn_nomg_maybeutf8
and avoid determining the utf8ness of the lhs beforehand.  But see-
ing that encoding.pm still exists, we have to prevent double overload
stringification the other way, by force-stringification of the target.

11 years agoDon’t leak when pushing on to read-only array
Father Chrysostomos [Fri, 2 Nov 2012 04:48:22 +0000 (21:48 -0700)]
Don’t leak when pushing on to read-only array

$ ./miniperl -Ilib -w -e 'warn $$; while(1){eval {push @-, ""}}'

Croak first instead of creating a new element to store in the
array first and letting av_store croak.

11 years agoDon't leak stderr from 'git describe' in cmpVERSION
Hugo van der Sanden [Fri, 2 Nov 2012 09:42:52 +0000 (09:42 +0000)]
Don't leak stderr from 'git describe' in cmpVERSION

11 years agoDetect empty git tag in cmpVERSION
Hugo van der Sanden [Fri, 2 Nov 2012 10:39:34 +0000 (10:39 +0000)]
Detect empty git tag in cmpVERSION

11 years agotest.pl: allow for undefs in eq_hash
Hugo van der Sanden [Mon, 29 Oct 2012 23:31:21 +0000 (23:31 +0000)]
test.pl: allow for undefs in eq_hash

It should be possible to compare hashes with undef values without
triggering warnings.

11 years agoFix /a++(?{})+$code_block/
Father Chrysostomos [Thu, 1 Nov 2012 21:49:35 +0000 (14:49 -0700)]
Fix /a++(?{})+$code_block/

This I would expect:

$ perl5.16.0 -wMre=eval -e '$x = "(?{})"; /a++(?{})+$x/x'
(?{})+ matches null string many times in regex; marked by <-- HERE in m/a++(?{})+ <-- HERE (?{})/ at -e line 1.
Use of uninitialized value $_ in pattern match (m//) at -e line 1.

It warns, but it still runs.

This I would not,

$ perl5.17.5 -wMre=eval -e '$x = "(?{})"; /a++(?{})+$x/x'
Nested quantifiers in regex; marked by <-- HERE in m/a++     + <-- HERE (?{})/ at (eval 1) line 1.

were it not for the fact that I know how it works. :-)

To compile the blocks in $x without recompiling the blocks directly
inside /.../, the regexp compiler blanks out the ‘outer’ blocks with
spaces, and compiles qr'a++     +(?{})'x.  But /x can see through
those spaces, resulting in a change in behaviour.  So use under-
scores instead.

11 years agoDon’t leak with /(?{})$invalid_code_block/
Father Chrysostomos [Thu, 1 Nov 2012 20:08:17 +0000 (13:08 -0700)]
Don’t leak with /(?{})$invalid_code_block/

This script was leaking:

$ ./perl -Ilib -wMre=eval -e '$x = "(?{+})"; while(1){eval {/(?{})$x/}}'

The mallocked array that is allocated before compilation to hold the
code blocks was not being freed before the syntax error from the inner
pattern ($x) was propagated.

11 years agoFree detritus when croaking with /(?{})$invalid/
Father Chrysostomos [Thu, 1 Nov 2012 13:19:28 +0000 (06:19 -0700)]
Free detritus when croaking with /(?{})$invalid/

This script was leaking:

$ ./miniperl -e 'warn $$; $x = ")"; while( 1){ eval { /(?{})$x/ }; }'

The mallocked array that is allocated before compilation to hold the
code blocks was not being protected properly around the first pass of
compilation.

11 years agoStop run-time regexp blocks from leaking regexps
Father Chrysostomos [Wed, 31 Oct 2012 17:02:03 +0000 (10:02 -0700)]
Stop run-time regexp blocks from leaking regexps

This was leaking like a sieve: $var = '(?{})'; /stuff$var/;

When a run-time regular expression has code blocks in it,
those are compiled separately inside their own qr thingy (see
S_compile_runtime_code in regcomp.c).

In re_op_compile, the newly-compiled code blocks are stored in
pRExC_state->code_blocks, which is a mallocked array.  That array also
holds reference counts on the regular expressions from which the code
blocks derive their existence.  When the whole regular expression is
compiled, the code blocks are fetched from that array, and the new
regular expression ends up holding a reference count on those code
block’s originating regular expressions.

The reference counts that pRExC_state->code_blocks had were not low-
ered when pRExC_state->code_blocks was freed, except for qr/stuff$var/
(because the qr// would take ownership of those reference counts,
which would be lowered when the outer qr// itself was freed).

11 years agoStop / $looks_like_block/ from leaking
Father Chrysostomos [Tue, 30 Oct 2012 23:41:27 +0000 (16:41 -0700)]
Stop / $looks_like_block/ from leaking

If an interpolated string looks as though it contains a regexp code
block, the regexp compiler will evaluate it inside qr'...' and then
extract the code blocks from the resulting regexp object.

If it turned out to be a false positive (e.g., "[(?{})]"), then
the code to handle this returned without freeing the temporary reg-
exp object.

11 years agoadd perl5.16.2 to perlhist
Ricardo Signes [Thu, 1 Nov 2012 14:20:20 +0000 (10:20 -0400)]
add perl5.16.2 to perlhist

11 years agoadd perl5162delta
Ricardo Signes [Thu, 1 Nov 2012 14:19:47 +0000 (10:19 -0400)]
add perl5162delta

11 years agoadd the 5.16.2 epigraph
Ricardo Signes [Thu, 1 Nov 2012 14:07:46 +0000 (10:07 -0400)]
add the 5.16.2 epigraph

11 years agoInitial (incomplete) patch to start restoring WinCE build
Konovalov, Vadim (Vadim)** CTR ** [Thu, 1 Nov 2012 14:03:34 +0000 (14:03 +0000)]
Initial (incomplete) patch to start restoring WinCE build

Subject: RE: status of WinCE Perl port in 2012
From: "Konovalov, Vadim (Vadim)** CTR **" <vadim.konovalov@alcatel-lucent.com>
Date: Tue, 23 Oct 2012 14:26:49 +0200
Message-ID: <35BF8D9716175C43BB9D67CA60CC345E028EE0C899@FRMRSSXCHMBSC2.dc-m.alcatel-lucent.com>

11 years agoRemove __attribute__malloc__ from MYSWAP functions
Steve Hay [Thu, 1 Nov 2012 13:43:39 +0000 (13:43 +0000)]
Remove __attribute__malloc__ from MYSWAP functions

These functions are only used when the native sockets functions are not
available, e.g. when building miniperl on Windows following commit
19253ae62c, so gcc's warning about ignoring the __malloc__ attribute here
is not normally seen.

The addition of "a" to these functions in embed.fnc by
commit f54cb97a39 was presumably wrong since none of them actually
allocate any memory (nor did so at the time), so change it to just "R"
(which is implied by the "a" and is still appropriate).

11 years agoWin32 miniperl: delay loading for Winsock, and then remove it
Daniel Dragan [Sat, 13 Oct 2012 23:37:33 +0000 (19:37 -0400)]
Win32 miniperl: delay loading for Winsock, and then remove it

Slim down the image and speed up start up time for Win32 miniperl by
removing Winsock. Also if the build process on Win32 in the future
requires sockets, commenting one line in win32.h will turn sockets back on
for miniperl, but this time with delay loading on VC Perl. The only casulty
of no sockets for Win32 miniperl was figuring out the computer's name in
win32/config_sh.PL. A workaround by using an ENV var was implemented. The
purpose of this commit is to speed up the build process of Perl.

As said in the comment in win32.h, the WIN32_NO_SOCKETS macro is
incomplete in implementation. It is only removed winsock from being linked
in in miniperl, not full Perl. PERL_IMPLICIT_SYS (specifically PerlSock in
win32/perlhost.h) and makedef.pl's hard coded list of win32_* function
exports cause winsock to still be linked in with even with
WIN32_NO_SOCKETS on full perl. Both PERL_IMPLICIT_SYS (win32/perlhost.h)
and makedef.pl would require changes to remove winsock from being linked
in on full perl in the future.

11 years agoAdd the DynaLoader upgrade to perldelta
Steve Hay [Wed, 31 Oct 2012 08:37:41 +0000 (08:37 +0000)]
Add the DynaLoader upgrade to perldelta

11 years agoUse correct type to avoid a cast added by fe1c5936a5
Steve Hay [Wed, 31 Oct 2012 08:36:58 +0000 (08:36 +0000)]
Use correct type to avoid a cast added by fe1c5936a5

(Suggested by Tony Cook.)

11 years agoBump DynaLoader's $VERSION after commit fe1c5936a5
Steve Hay [Wed, 31 Oct 2012 08:25:25 +0000 (08:25 +0000)]
Bump DynaLoader's $VERSION after commit fe1c5936a5