This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
10 years agoprevent lib/File/stat.t from aborting at END on cygwin
Tony Cook [Tue, 11 Jun 2013 12:38:43 +0000 (22:38 +1000)]
prevent lib/File/stat.t from aborting at END on cygwin

cygwin appears to be unique in that it uses fast_abs_path() for
abs_path() and vaguely follows POSIX semantics on directory permissions.

Previously the tempdir created would be chmod() to 0600 (non-executable)
and fast_abs_path() would croak when it couldn't chdir into the
directory.

10 years agoperldelta: typo
Father Chrysostomos [Tue, 11 Jun 2013 05:22:05 +0000 (22:22 -0700)]
perldelta: typo

10 years agoperldelta: ">" was missing its "C<"
Karl Williamson [Tue, 11 Jun 2013 02:41:56 +0000 (20:41 -0600)]
perldelta: ">" was missing its "C<"

10 years agopod/perldelta: Add note about documenting toLOWER() etc
Karl Williamson [Tue, 11 Jun 2013 02:41:09 +0000 (20:41 -0600)]
pod/perldelta: Add note about documenting toLOWER() etc

10 years agoQuantifier follows nothing in regex
Karl Williamson [Tue, 11 Jun 2013 02:07:14 +0000 (20:07 -0600)]
Quantifier follows nothing in regex

This changes the code so that any '?' immediately (subject to /x rules)
following a {0} quantifier is absorbed immediately as part of that
quantifier.  This allows the optimization to NOTHING to work for
non-greedy matches.

Thanks to Yves Orton for doing most of the leg work on this

10 years agocorrect omission of File::CheckTree and Text::Soundex from deprecations
Ricardo Signes [Mon, 10 Jun 2013 23:03:45 +0000 (19:03 -0400)]
correct omission of File::CheckTree and Text::Soundex from deprecations

10 years agoperldelta for debugger @_ fix
Ricardo Signes [Mon, 10 Jun 2013 22:19:53 +0000 (18:19 -0400)]
perldelta for debugger @_ fix

10 years agoFix the mutability of @_ in perl -d.
Shlomi Fish [Sun, 26 May 2013 15:55:48 +0000 (18:55 +0300)]
Fix the mutability of @_ in perl -d.

With a test.

See Father C.'s comment on RT #118169.

10 years agoFix for RT #118169
Shlomi Fish [Sun, 26 May 2013 13:35:04 +0000 (16:35 +0300)]
Fix for RT #118169

https://rt.perl.org/rt3/Public/Bug/Display.html?id=118169

subroutine arguments are no longer shown in perl debugger ( x @_ in perl
-d) .

Regression from perl-5.16.x due to the perl -d refactoring. Fixed with a
test.

10 years agoBenchmark.t: test for inconsistent clock
David Mitchell [Mon, 10 Jun 2013 16:04:46 +0000 (17:04 +0100)]
Benchmark.t: test for inconsistent clock

test 15 has been failing intermittently in smokes for ages now.
This does countit(3, ...) and countit(1, ...) and checks that the first
takes approx three times longer than the second.

This commit adds in near the beginning a crude timing loop that directly
uses times() rather than anything in the Benchmark module, and that does
approx 1s and 3s of loops, and if the results aren't consistent, sets a
global flag, $INCONSISTENT_CLOCK, that causes timing-sensitive tests to be
skipped.

For now it only skips test 15. If this is successful, I'll look to
expand it to other failing tests like 128/129.

10 years agoOn Win32, i_rpcsvcdbm should be 'undef' as there is no <rpcsvc/dbm.h>
Nicholas Clark [Thu, 6 Jun 2013 10:51:58 +0000 (12:51 +0200)]
On Win32, i_rpcsvcdbm should be 'undef' as there is no <rpcsvc/dbm.h>

3 canned Win32 config files had i_rpcsvcdbm as 'define', and consequently
their generated headers had I_RPCSVC_DBM defined. This symbol means that
a header file <rpcsvc/dbm.h> exists and should be included. However, it's
only used by ODBM_File, which is not built on Win32, so nothing ever noticed
the error.

The errors in the header files seem to date from commit 0a753a764065f226
("[inseparable changes from patch from perl5.003_23 to perl5.003_24]" in
Jan 1997), which added the Win32 port. The config file, win32/config.w32,
has i_rpcsvcdbm as 'undef' but the header file win32/config.h is
inconsistent, with I_RPCSVC_DBM defined.

The errors in the canned configs seem to date from commit 68dc074516a6859e
("[inseparable changes from match from perl-5.003_93 to perl-5.003_94]" in
March 1997), where the value of i_rpcsvcdbm was changed in win32/config.w32

10 years agoRMG: need to update Module::CoreList again after blead release
David Golden [Mon, 10 Jun 2013 11:32:37 +0000 (07:32 -0400)]
RMG: need to update Module::CoreList again after blead release

10 years agoperldelta for recent BUILD_STATIC/ALL_STATIC changes
Steve Hay [Mon, 10 Jun 2013 08:32:58 +0000 (09:32 +0100)]
perldelta for recent BUILD_STATIC/ALL_STATIC changes

10 years agoperldelta: DB has not been removed
Father Chrysostomos [Mon, 10 Jun 2013 08:24:01 +0000 (01:24 -0700)]
perldelta: DB has not been removed

10 years agoperldelta for double quantifier warnings (688e039)
Father Chrysostomos [Mon, 10 Jun 2013 08:18:10 +0000 (01:18 -0700)]
perldelta for double quantifier warnings (688e039)

10 years agoperldelta for File::Spec->tmpdir and changing env (#88940)
Father Chrysostomos [Mon, 10 Jun 2013 08:15:34 +0000 (01:15 -0700)]
perldelta for File::Spec->tmpdir and changing env (#88940)

10 years agoIncrease $File::Spec::VERSION to 3.41
Father Chrysostomos [Mon, 10 Jun 2013 08:13:45 +0000 (01:13 -0700)]
Increase $File::Spec::VERSION to 3.41

to match the version number increases in some of the submodules and
to make the perldelta entry easier to describe.

10 years agoperldelta for PL_stashcacheh and glob-to-glob assignment (210fdecd4)
Father Chrysostomos [Mon, 10 Jun 2013 08:12:26 +0000 (01:12 -0700)]
perldelta for PL_stashcacheh and glob-to-glob assignment (210fdecd4)

10 years agoperldelta for freed stashes (#117941)
Father Chrysostomos [Mon, 10 Jun 2013 08:04:18 +0000 (01:04 -0700)]
perldelta for freed stashes (#117941)

10 years agoperldelta for sort/require CORE:: (#24482)
Father Chrysostomos [Mon, 10 Jun 2013 08:02:38 +0000 (01:02 -0700)]
perldelta for sort/require CORE:: (#24482)

10 years agoperldealt for delete local $ENV{x} leaking (9332b95f7)
Father Chrysostomos [Mon, 10 Jun 2013 08:00:54 +0000 (01:00 -0700)]
perldealt for delete local $ENV{x} leaking (9332b95f7)

10 years agoperldelta for (?[]) fixes
Father Chrysostomos [Mon, 10 Jun 2013 07:59:46 +0000 (00:59 -0700)]
perldelta for (?[]) fixes

10 years agoperldelta for #117595 (-l warning)
Father Chrysostomos [Mon, 10 Jun 2013 07:56:37 +0000 (00:56 -0700)]
perldelta for #117595 (-l warning)

10 years agoperldelta for deparsing ${#}{foo} (#117531)
Father Chrysostomos [Mon, 10 Jun 2013 07:55:15 +0000 (00:55 -0700)]
perldelta for deparsing ${#}{foo} (#117531)

10 years agoperldelta for JS in perltrap
Father Chrysostomos [Mon, 10 Jun 2013 07:54:08 +0000 (00:54 -0700)]
perldelta for JS in perltrap

10 years agoperldelta for #117311/B::Deparse -l and FF
Father Chrysostomos [Mon, 10 Jun 2013 07:52:56 +0000 (00:52 -0700)]
perldelta for #117311/B::Deparse -l and FF

10 years agoperldelta: typo
Father Chrysostomos [Mon, 10 Jun 2013 07:51:37 +0000 (00:51 -0700)]
perldelta: typo

10 years agoperldelta for lexsub syntax errors (3a74e0e282c)
Father Chrysostomos [Mon, 10 Jun 2013 07:50:47 +0000 (00:50 -0700)]
perldelta for lexsub syntax errors (3a74e0e282c)

10 years agoperldelta for two lexsub fixes
Father Chrysostomos [Mon, 10 Jun 2013 07:49:26 +0000 (00:49 -0700)]
perldelta for two lexsub fixes

10 years agoperldelta for constant inlining (70e5f2b5)
Father Chrysostomos [Mon, 10 Jun 2013 07:46:51 +0000 (00:46 -0700)]
perldelta for constant inlining (70e5f2b5)

10 years agoperldelta for deparsing for my $x (#117081)
Father Chrysostomos [Mon, 10 Jun 2013 07:43:35 +0000 (00:43 -0700)]
perldelta for deparsing for my $x (#117081)

10 years agoperldelta for 3036c853/\N{} deprecations
Father Chrysostomos [Mon, 10 Jun 2013 07:39:36 +0000 (00:39 -0700)]
perldelta for 3036c853/\N{} deprecations

10 years agoperldelta for #118159 (SvTRUE on ""/1 dualvar)
Father Chrysostomos [Mon, 10 Jun 2013 07:36:03 +0000 (00:36 -0700)]
perldelta for #118159 (SvTRUE on ""/1 dualvar)

10 years agoperldiag: Document ‘Can't call mro_isa_changed_in’
Father Chrysostomos [Mon, 10 Jun 2013 07:23:18 +0000 (00:23 -0700)]
perldiag: Document ‘Can't call mro_isa_changed_in’

10 years agoperlfunc: Document fallback to "top" format
Father Chrysostomos [Mon, 10 Jun 2013 07:18:07 +0000 (00:18 -0700)]
perlfunc: Document fallback to "top" format

perl 4’s perl.man says this:

By default the top‐of‐page format is "top", but it may be set to the
format of your choice by assigning the name to the $^ variable.

This is still the case, but is completely undocumented in perl 5.

In perl 5 the presence of a <FILEHANDLE_NAME>_TOP format will over-
ride "top", as will $^, but "top" is still checked for in the
absence of those.

This should be documented.  One thing I do mention here that perl 4
omits is that it is "top" in the current package.

I also tweaked the wording of the preceding sentence.

10 years agodiag.t: Remove more nonexistent exceptions
Father Chrysostomos [Mon, 10 Jun 2013 07:12:16 +0000 (00:12 -0700)]
diag.t: Remove more nonexistent exceptions

10 years agoMake ‘make regen’ regenerate the tree in perllexwarn
Father Chrysostomos [Mon, 10 Jun 2013 06:27:19 +0000 (23:27 -0700)]
Make ‘make regen’ regenerate the tree in perllexwarn

‘perl regen/warnings.pl tree’ would already generate the tree, but it
had to be run separately and then copied and pasted into perllexwarn.
Now regen/warnings.pl modifies perllexwarn in place as part of its
regeneration.  The ‘tree’ command line argument will still cause the
tree to be output to STDOUT.

This causes the three missing experimental categories to be listed in
perllexwarn, resolving ticket #118369.

10 years agodiag.t: Remove nonexistent exception
Father Chrysostomos [Mon, 10 Jun 2013 06:19:55 +0000 (23:19 -0700)]
diag.t: Remove nonexistent exception

10 years agoStop /(a|b)(?=a){3}/ from warning twice
Father Chrysostomos [Mon, 10 Jun 2013 01:42:47 +0000 (18:42 -0700)]
Stop /(a|b)(?=a){3}/ from warning twice

[sprout@dromedary-001 perl2.git]$ ../perl.git/Porting/bisect.pl --target=miniperl  --start=perl-5.8.0 --end=v5.10.0   -- ./miniperl -Ilib -we 'BEGIN { $SIG{__WARN__} = sub { die if $_[0] =~ /Quantifier/ && $warned++; warn shift }}; ""=~/(N|N)(?{})?/'
...
07be1b83a6b2d24b492356181ddf70e1c7917ae3 is the first bad commit
commit 07be1b83a6b2d24b492356181ddf70e1c7917ae3
Author: Yves Orton <demerphq@gmail.com>
Date:   Fri Jun 9 02:56:37 2006 +0200

    Re: [PATCH] Better version of the Aho-Corasick patch and lots of benchmarks.
    Message-ID: <9b18b3110606081556t779de698r82f361d82a05fbc8@mail.gmail.com>

    (with tweaks)

    p4raw-id: //depot/perl@28373

Since that commit, it has been possible for S_study_chunk to be called
twice if the trie optimisation kicks in (which happens for /(a|b)/).
‘Quantifier unexpected on zero-length expression’ is the only warning
in S_study_chunk.  Now it can appear twice if the quantified zero-
length expression is in the same regexp as a trie optimisation.

So pass a flag to S_study_chunk when ‘restudying’ to indicate that the
warning should be skipped.

There are two code paths that call S_study_chunk, one for when there
is no top-level alternation, which triggers the error in this case,
and one for when there is a top-level alternation (/a|b/).  I wasn’t
able to figure out how to trigger the double warning in the second
case, but I passed the flag for the restudy in that code path anyway,
since I don’t think it can be wrong.

10 years agoRemove ‘bad top format’ error
Father Chrysostomos [Mon, 10 Jun 2013 00:30:56 +0000 (17:30 -0700)]
Remove ‘bad top format’ error

This is unreachable.  It only happens in pp_leavewrite when IoTOP_GV(io)
is null, but the code leading up to it makes sure that IoTOP_GV(io) is not
null.  If it is still null, it jumps past the error with ‘goto forget_top’.

10 years agoperldiag: Tweak ‘'%c' allowed only after types’
Father Chrysostomos [Sun, 9 Jun 2013 21:37:50 +0000 (14:37 -0700)]
perldiag: Tweak ‘'%c' allowed only after types’

by adding ‘in %s’ to the end.  Though strictly unnecessary, having
more of the unvarying parts of the string displayed in perldiag is
generally a good thing, and this also appeases diag.t.  (The former is
my main reason for the change, the latter incidental.)

10 years agoBump version in Carp::Heavy.
James E Keenan [Sun, 26 May 2013 02:52:00 +0000 (04:52 +0200)]
Bump version in Carp::Heavy.

10 years agoCarp: Don't autovivify the CARP_NOT or ISA array
Brian Fraser [Mon, 13 May 2013 19:37:22 +0000 (16:37 -0300)]
Carp: Don't autovivify the CARP_NOT or ISA array

In this situation:

    use Carp;
    package Foo;
    $CARP_NOT = 1;
    warn *{$Foo::{CARP_NOT}}{ARRAY} || 'undefined';
    eval { Carp::croak(1) };
    warn *{$Foo::{CARP_NOT}}{ARRAY} || 'undefined';

The second warn shows that Carp is autovivifying the ARRAY slot
of the glob.  This commit builds on the previous and checks that
the array exists before trying to use it.

10 years agoCarp: Stop polluting the caller's namespace if they lack @CARP_NOT or @ISA
Brian Fraser [Mon, 13 May 2013 18:57:18 +0000 (15:57 -0300)]
Carp: Stop polluting the caller's namespace if they lack @CARP_NOT or @ISA

Turns out that this:

perl -MCarp -le 'package Foo; eval { Carp::croak(1) }; print keys %Foo::;'

Would leave two new symbols in Foo, CARP_NOT and ISA. This commit
changes trusts_directly() to check if the symbols exists in the
stash before using them.

10 years agoAUTHORS: Use tabs consistently
Father Chrysostomos [Sun, 9 Jun 2013 19:00:32 +0000 (12:00 -0700)]
AUTHORS: Use tabs consistently

Since this is not just a source file, but a file to be read by the public
as is, we cannot mix tabs and spaces.

10 years agopodcheck.t: Use scalar instead of array
Father Chrysostomos [Sun, 9 Jun 2013 18:27:17 +0000 (11:27 -0700)]
podcheck.t: Use scalar instead of array

The contents of @thankful_diagnostics are never used, only the length.
So it can simply be a scalar containing a count.

10 years agoSynchronize pod2html usage output and its POD text
Petr Písař [Sun, 9 Jun 2013 18:14:24 +0000 (14:14 -0400)]
Synchronize pod2html usage output and its POD text

10 years agoadd Petr Písař to the AUTHORS file
Ricardo Signes [Sun, 9 Jun 2013 18:02:18 +0000 (14:02 -0400)]
add Petr Písař to the AUTHORS file

10 years agoSynchronize h2ph POD text with usage output
Petr Písař [Sun, 9 Jun 2013 18:01:49 +0000 (14:01 -0400)]
Synchronize h2ph POD text with usage output

10 years agotweak perltw.pod for long lines (and default exports)
Ricardo Signes [Sun, 9 Jun 2013 15:37:13 +0000 (11:37 -0400)]
tweak perltw.pod for long lines (and default exports)

10 years agoadd gugod to the AUTHORS file
Ricardo Signes [Sun, 9 Jun 2013 15:33:57 +0000 (11:33 -0400)]
add gugod to the AUTHORS file

10 years agoRemove references of "encoding" module in README.tw
Kang-min Liu [Sat, 11 May 2013 18:00:53 +0000 (20:00 +0200)]
Remove references of "encoding" module in README.tw

10 years agouse more descriptive examples in File::Copy
Zsbán Ambrus [Sun, 9 Jun 2013 14:50:06 +0000 (10:50 -0400)]
use more descriptive examples in File::Copy

10 years agonote that the return value of for is unspecified
Ricardo Signes [Sun, 9 Jun 2013 13:41:45 +0000 (09:41 -0400)]
note that the return value of for is unspecified

[perl #118121]

10 years agodocument the /p flag and related variables in delta
Zsban Ambrus [Sun, 9 Jun 2013 13:26:22 +0000 (09:26 -0400)]
document the /p flag and related variables in delta

10 years agoremove -Dmad string length restriction
David Mitchell [Sun, 9 Jun 2013 09:50:15 +0000 (10:50 +0100)]
remove -Dmad string length restriction

Under -Dmad, with PERL_MADSKILLS > 0, it prints a warning for every
string that is grown to be >= 1Mb. I can't see that it makes any sense to
do this, so I suspect that this is residual code from MAD development, or
an accidental copying of the almost identical #ifdef HAS_64K_LIMIT
piece of code directly following it.

10 years agoIncrease some File::Spec versions to 3.41
Father Chrysostomos [Sun, 9 Jun 2013 06:10:18 +0000 (23:10 -0700)]
Increase some File::Spec versions to 3.41

10 years agoCorrect File::Spec POD about tainting and tmpdir
Father Chrysostomos [Sun, 9 Jun 2013 06:03:56 +0000 (23:03 -0700)]
Correct File::Spec POD about tainting and tmpdir

Since version 3.39_01, the taint check has applied before 5.8.0, too.

10 years ago[perl #89940] File::Spec->tmpdir and env changes
Father Chrysostomos [Sun, 9 Jun 2013 06:01:07 +0000 (23:01 -0700)]
[perl #89940] File::Spec->tmpdir and env changes

If the environment changes, File::Spec->tmpdir should respect that and
recalculate the temp directory.

The only objection raised in the ticket was that File::Spec is already
accused of being too slow, so removing the cache would not be a good
idea.  So I put in a check to see whether the relevant environment
variables have changed since the last call to tmpdir.

10 years agoFile::Spec::Epoc: Small pod clean-up
Father Chrysostomos [Sun, 9 Jun 2013 05:33:24 +0000 (22:33 -0700)]
File::Spec::Epoc: Small pod clean-up

10 years agoFlush PL_stashcache on glob-to-glob assignment
Father Chrysostomos [Sat, 8 Jun 2013 21:38:02 +0000 (14:38 -0700)]
Flush PL_stashcache on glob-to-glob assignment

Commit dc93d7fb33f6b2093 says this:

    Flush PL_stashcache when assigning a file handle to a typeglob.

    File handles take priority over stashes for method dispatch.
    Assigning a file handle to a typeglob potentially creates a file
    handle where one did not exist before.  As PL_stashcache only con-
    tains entries for names which unambiguously resolve to stashes,
    such a change may mean that PL_stashcache now contains an invalid
    entry.  As it’s hard to work out exactly which entries might be
    affected, simply flush the entire cache and let it rebuild itself.

But it only applied to io-to-glob assignment.  This commit extends it
to glob-to-glob assignment.

10 years agopp_hot.c: Correct comment
Father Chrysostomos [Sat, 8 Jun 2013 21:13:21 +0000 (14:13 -0700)]
pp_hot.c: Correct comment

At this point, ob holds the object the reference points to, not the
reference itself.

10 years agopodcheck.t: Output fixed problems as passing to-do tests
Father Chrysostomos [Sat, 8 Jun 2013 21:07:38 +0000 (14:07 -0700)]
podcheck.t: Output fixed problems as passing to-do tests

10 years agoImprove fileno example
Dominic Hargreaves [Sun, 9 Jun 2013 00:28:50 +0000 (01:28 +0100)]
Improve fileno example

Quoting from the fileno section of this document:

"[...]  If there is no real file descriptor at the OS level, as can
happen with filehandles connected to memory objects via "open" with a
reference for the third argument, -1 is returned."

Update the example to cater for this situation. Thanks to
Niels Thykier for the suggestion.

Bug-Debian: http://bugs.debian.org/706749

10 years agoadd 1 to SvGROW under COW (and fix svleak.t)
David Mitchell [Sat, 8 Jun 2013 17:24:51 +0000 (18:24 +0100)]
add 1 to SvGROW under COW (and fix svleak.t)

the new COW scheme uses SvPVX(sv)[SvLEN(sv)-1] (if spare)
to store the COW reference count. If this byte isn't spare, the string is
copied rather than COWed.  So, when built under the new COW, allocate one
more byte than asked for in sv_grow(), to make it likely this byte is
always spare: and thus make more strings COW-able. If the new size is a
big power of two, don't bother: we assume the caller wanted a nice 2^N
sized block and will be annoyed at getting 2^N+1 or more.

Note that sv_grow() already rounds up. For example: formerly, strings of
length 1..15 were allocated 16 bytes, 16..31 allocated 32 bytes, etc
(usually allowing +1 for trailing \0).

Now its 1..14 => 16, 15..30 => 32 etc.

As a side-effect, this should fix a bizarre occasionally failing svleak.t
test under COW. This test,

    '"too many errors" from constant overloading returning undef'

basically twice evals some code that is expected to fail. If over the
course of the second eval the total number of allocated SVs grows, then
the test fails. This particular eval uses overload::constant, and that
module has this code:

    "$_[1]" !~ /(^|=)CODE\(0x[0-9a-f]+\)$/

i.e. match against a stringified reference. Now, if it stringifies to a
15-char string (e.g. "CODE(0x1234567)"), then SvCUR is 15 and SvLEN is 16,
and there isn't a spare byte (after allowing for \0) for the COW ref
count, so the string can't be COWed. Now, if during the first eval,
addresses are in the range 0x1000000..0xfffffff, then COW doesn't kick in.
If during the second eval they fall outside this range, COW kicks in, and
a new SV (which is a COW copy of the string) is attached to the regex, for
capture info. This new SV won't be released until the regex is released,
and so appears to be a leak. If COW kicks in during the first eval then
this isn't an issue, as it will just be reused during the second eval.

This was exceedingly difficult to reliably reproduce, as it was heavily
affected by kernel address randomisation (on linux); plus part of the test
file used rand(); plus of course the hash randomisation and perturbation
feature in 5.18.

I eventually cracked it by: tweaking the hash randomisation; hacking the
perl seed code to use an ENV var rather than /dev/urandom; hacking the
perl startup to display the initial system brk(), then when it failed,
hacked it again to set that particular brk().

10 years ago[perl #117941] reset crashes when current stash is freed
Father Chrysostomos [Sat, 8 Jun 2013 07:23:02 +0000 (00:23 -0700)]
[perl #117941] reset crashes when current stash is freed

10 years agoperldiag: typo
Father Chrysostomos [Sat, 8 Jun 2013 07:11:40 +0000 (00:11 -0700)]
perldiag: typo

10 years ago[perl #117941] eval crashes when current stash is freed
Father Chrysostomos [Sat, 8 Jun 2013 07:11:23 +0000 (00:11 -0700)]
[perl #117941] eval crashes when current stash is freed

10 years ago[perl #117941] Blessing into freed current stash
Father Chrysostomos [Sat, 8 Jun 2013 06:56:23 +0000 (23:56 -0700)]
[perl #117941] Blessing into freed current stash

If the current stash has been freed, bless() with one argument will
cause a crash when the object’s ‘stash’ is accessed.  Simply disallow-
ing this is the easiest fix.

10 years ago[perl #117941] Handle vivification crashing w/freed stash
Father Chrysostomos [Sat, 8 Jun 2013 06:41:32 +0000 (23:41 -0700)]
[perl #117941] Handle vivification crashing w/freed stash

open’s handle vivification could crash if the current stash was freed,
so check before passing a freed stash to gv_init.

10 years agoStop using PL_sortstash
Father Chrysostomos [Sat, 8 Jun 2013 06:28:38 +0000 (23:28 -0700)]
Stop using PL_sortstash

Originally, the value of PL_sortstash was used to determine whether
PL_firstgv and PL_secondgv (which point to *a and *b in the current
package) needed to be updated (involving symbol lookup).  PL_sortstash
would contain the last package sorted in.  If PL_sortstash did not
point to the current stash, then they would be updated, along with
PL_sortstash.

Sort was made reëntrant in 2000 in commit 8e664e1028b.  This involved
saving and restoring the values of PL_firstgv and PL_secondgv via the
savestack.  The logic introduced by that commit was thus:

+               if (PL_sortstash != stash || !PL_firstgv || !PL_secondgv) {
+                   SAVESPTR(PL_firstgv);
+                   SAVESPTR(PL_secondgv);
+                   PL_firstgv = gv_fetchpv("a", TRUE, SVt_PV);
+                   PL_secondgv = gv_fetchpv("b", TRUE, SVt_PV);
+                   PL_sortstash = stash;
+               }

PL_firstgv and PL_secondgv would be null if no sort were already hap-
pening, causing this block to be executed.  For a nested sort, this
would only be executed if the nested sort were in a different package
from the outer sort.

Because the value of PL_sortstash was not being restored, this block
would not trigger the second time the outer sort called the inner sort
(in a different package).  This was bug #36430 (a duplicate of #7063).

This was fixed in commit 9850bf21fc4e, which did not explain anything
in its commit message.  A preliminary version of the patch was submit-
ted for review in <20051026173901.GA3105@rpc142.cs.man.ac.uk>, which
mentions that the patch fixes bug #36430.

It fixed the bug by localising the value of PL_sortstash, causing the
if() condition to become redundant, so that was removed.

Now, it happened that that if() condition was the only place that
PL_sortstash was used.  So if we are going to localise PL_firstgv
and PL_secondgv unconditionally when sorting, PL_sortstash serves
no purpose.

While I could restore the if() condition and leave the localisation of
PL_sortstash in place, that would only benefit code that does nested
sort calls in the same package, which is rare, and the resulting
speed-up is barely measurable.

PL_sortstash is referenced by some CPAN modules, so I am taking
the cautious route of leaving it in for now, though the core
doesn’t use it.

10 years ago[perl #24482] Fix sort and require to treat CORE:: as keyword
Father Chrysostomos [Sat, 8 Jun 2013 03:16:23 +0000 (20:16 -0700)]
[perl #24482] Fix sort and require to treat CORE:: as keyword

10 years agoAllow qr/(?[ [a] ])/ interpolation in (?[...])
Father Chrysostomos [Sat, 8 Jun 2013 01:14:43 +0000 (18:14 -0700)]
Allow qr/(?[ [a] ])/ interpolation in (?[...])

Interpolation fails if the interpolated extended character class con-
tains any bracketed character classes itself.

The sizing pass looks for [ and passes control to the regular charac-
ter class parser.  When the charclass is finished, it begins scanning
for [ again.  If it finds ], it assumes it is the end.

That fails with (?[  (?a:(?[  [a]  ]))  ]).  The sizing pass hands
[  [a]  ]... off to the charclass parser, which parses [  [a] and
hands control back to the sizing pass.  It then sees ‘  ]))  ])’,
assumes that the first ]) is the end of the entire construct, so the
main regexp parser sees the parenthesis following and dies.

If we change the sizing pass to look for ?[ we can simply record the
depth (depth++) and then when we see ] decrement the depth or exist
the loop if it is zero.

10 years agoperldiag: Correct descr of ‘Expecting '(?flags:(?[...'’
Father Chrysostomos [Fri, 7 Jun 2013 20:13:46 +0000 (13:13 -0700)]
perldiag: Correct descr of ‘Expecting '(?flags:(?[...'’

I did not realise at first that (?:(?[...])) is forbidden.

10 years agoInclude the Encode extension in the ALL_STATIC build on Win32 for VC++
Steve Hay [Sat, 8 Jun 2013 01:16:17 +0000 (02:16 +0100)]
Include the Encode extension in the ALL_STATIC build on Win32 for VC++

Thanks to Jan Dubois and Nicholas Clark for pointing out that Encode has
subextensions which need statically linking too, and that Configure has
a special case for handling this which we can mimic in config_sh.PL.

Unfortunately, however, while this works for VC++, with MinGW it gives
undefined reference errors to three symbols from Encode/CN.o
(_cp936_encoding, _euc_cn_encoding and MacChineseSimp_encoding) and two
from Encode/JP.o (_cp932_encoding and _euc_jp_encoding), so we must retain
the exclusion on Encode for MinGW for now, much like the Compress/Raw/Bzip2
problem found before. Hopefully these are all fixable soon.

10 years agoInclude the Win32 extension in the ALL_STATIC build on Win32
Steve Hay [Fri, 7 Jun 2013 22:47:12 +0000 (23:47 +0100)]
Include the Win32 extension in the ALL_STATIC build on Win32

Many of Win32's Perl level functions are pre-defined (even without a "use
Win32" statement), while the implementation is in a dynamically linked
module. This is done via the statically linked Win32CORE wrapper that will
load Win32 on demand. The initialization of Win32CORE (init_Win32CORE()) is
called -- dynamically, via GetProcAddress(), since miniperl.exe doesn't
include it -- from Perl_init_os_extras() and normally relies on the DLL's
HANDLE having been set in the DLL_PROCESS_ATTACH case of DllMain() in
perllib.c. We must use a different HANDLE when the functions are located in
perl-static.exe since DllMain() is not called in that case, and, in fact,
it is sensible to consider other parts of DllMain() which
Perl_init_os_extras() might also need to do...

The #ifdef DEFAULT_BINMODE section can be scrapped completely since the
symbol is not defined, never mentioned anywhere else and not documented.
The DisableThreadLibraryCalls() call is not applicable for code that
doesn't reside in a DLL. That just leaves set_w32_module_name(), but that
is not required either, and may actually be redundant in the DllMain() case
too (maybe I will remove it later).

The last-but-one thing to do is to arrange for init_Win32CORE to be
exported from perl-static.exe (as it already is from perl519.dll, courtesy
of makedef.pl) otherwise GetProcAddress() won't find it. I see no harm in
always specifying __declspec(dllexport) in Win32CORE.c (except in one
existing Cygwin case which doesn't want it, which I'm not touching to
minimize regression risk). I thought that the .def file entry written by
makedef.pl for perl519.dll would then become redundant, and whilst the VC++
build worked fine without it, the MinGW build didn't: init_Win32CORE no
longer got exported from perl519.dll, thus breaking the normal build, so
I've therefore left makedef.pl alone.

The very last thing to do in some future change is to improve the
ALL_STATIC build so that Win32 functions like CopyFile() do not go
through Win32CORE's w32_CORE_all forwarding function as they currently do:
it isn't necessary when Win32 is statically linked as well! I will revisit
this part very soon...

Thanks to Jan Dubois and all the others in the following thread for
invaluable assistance in this and other recent changes in this area:
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2013-06/msg00016.html

10 years agoversion bumps and perldelta for debugger depth
Ricardo Signes [Fri, 7 Jun 2013 15:51:45 +0000 (11:51 -0400)]
version bumps and perldelta for debugger depth

10 years agoadjust $DB::deep from 100 to 1000
Mark Jason Dominus [Fri, 7 Jun 2013 15:42:07 +0000 (11:42 -0400)]
adjust $DB::deep from 100 to 1000

$DB::deep defaults to 100; this means that when the debugger gets 100
levels deep in subroutine calls, it automatically breaks execution.
While this might have been appropriate in 1989, in modern Perl programs,
the debugger might break before the program is even compiled.

This patch adjusts the default value up to 1000.

I was not able to find the default value documented anywhere.

10 years agoStop delete local $ENV{foo} from leaking
Father Chrysostomos [Fri, 7 Jun 2013 15:26:03 +0000 (08:26 -0700)]
Stop delete local $ENV{foo} from leaking

It was only leaking when the env var did not already exist.

The code in question in pp.c:S_do_delete_local was calling hv_delete
to delete the element, which autovivifies, deletes, and returns a mag-
ical mortal for magical hashes.  It was assuming that if a value was
returned the element must have existed, so it was calling SvREFCNT_inc
on the returned mortal to de-mortalize it (since it has to be
restored).  Whether the element had existed previously was already
recorded in a bool named ‘preeminent’ (strange name).  This variable
should be checked before the SvREFCNT_inc.

I found the same bug in the array code path, potentially affecting
@- and @+, so I fixed it.  But I didn’t write a test, as that would
involve a custom regexp engine.

10 years agohv.c: Clarify uvar comment
Father Chrysostomos [Fri, 7 Jun 2013 03:42:30 +0000 (20:42 -0700)]
hv.c: Clarify uvar comment

It was not clear that it referred to uvar magic.

10 years agoDon’t leak when compiling /(?[\d\d])/
Father Chrysostomos [Thu, 6 Jun 2013 21:14:06 +0000 (14:14 -0700)]
Don’t leak when compiling /(?[\d\d])/

The ‘Operand with no preceding operator’ error was leaking the last
two operands.

10 years agoFree operand when encountering unmatched ')' in (?[])
Father Chrysostomos [Thu, 6 Jun 2013 21:07:21 +0000 (14:07 -0700)]
Free operand when encountering unmatched ')' in (?[])

I only need to free the operand (current), not the left-paren token
that turns out not to be a paren (lparen).

For lparen to leak, there would have to be two operands in a row on
the charclass parsing stack, which currently never happens.

10 years agoStop /(?[\p{...}])/ compilation from leaking
Father Chrysostomos [Thu, 6 Jun 2013 20:42:32 +0000 (13:42 -0700)]
Stop /(?[\p{...}])/ compilation from leaking

The swash returned by utf8_heavy.pl was not being freed in the code
path to handle returning character classes to the (?[...]) parser
(when ret_invlist is true).

10 years agoAdd a note to Win32's BUILD_STATIC configuration to include Win32CORE
Steve Hay [Thu, 6 Jun 2013 22:48:56 +0000 (23:48 +0100)]
Add a note to Win32's BUILD_STATIC configuration to include Win32CORE

Win32CORE needs to be included for the on-demand loading of Win32 to work.
(Many of Win32's Perl level functions are pre-defined (even without a "use
Win32" statement), while the implementation is in a dynamically linked
module.)

10 years agoExclude Compress/Raw/Bzip2 from ALL_STATIC extensions for MinGW for now
Steve Hay [Thu, 6 Jun 2013 22:43:33 +0000 (23:43 +0100)]
Exclude Compress/Raw/Bzip2 from ALL_STATIC extensions for MinGW for now

The ALL_STATIC=define build succeeds with VC++, but with MinGW it gives an
error about _BZ2_compressBlock (referenced from bzlib.o) being undefined.
I do not know why, so just exclude this extension from the list for now,
and add a note about it.

10 years agoSimplify recipes for making perl-static.exe on Win32
Steve Hay [Thu, 6 Jun 2013 22:35:55 +0000 (23:35 +0100)]
Simplify recipes for making perl-static.exe on Win32

There is no need to link the static extension libraries as well as the
static perl library because the entire contents of all the static extension
libraries have been put into the static perl library anyway.

Also put the list of objects and libraries which perl.exe and
perl-static.exe link against in the same order as each other, and in both
makefiles, and (in makefile.mk) for both compilers, so that the
similarities and differences are more readily seen.

10 years agoFix creation of libperl519s.a on Win32 with MinGW
Steve Hay [Thu, 6 Jun 2013 22:28:07 +0000 (23:28 +0100)]
Fix creation of libperl519s.a on Win32 with MinGW

The "ar rc" command created an invalid static perl library by putting the
static extension libraries themselves into the library rather than putting
the objects from each static extension library into it as intended (like
the VC++ "link -lib" command does).

We now extract each static extension library's objects into a temporary
directory and put the objects from there into the static perl library.

10 years agoRemove /PDB:NONE linker option from Win32 makefiles
Steve Hay [Thu, 6 Jun 2013 22:14:09 +0000 (23:14 +0100)]
Remove /PDB:NONE linker option from Win32 makefiles

The /PDB linker option syntax changed from /PDB:{filename|NONE} to just
/PDB:filename from VC7 onwards. We do not use /PDB:NONE for most targets
anyway, so just remove it from the one place it is present to avoid
accidentally creating a file called "NONE" with all but VC6.

10 years agoEnsure Win32 [nd]make builds the 'static' target when ALL_STATIC=define
Steve Hay [Thu, 6 Jun 2013 22:05:05 +0000 (23:05 +0100)]
Ensure Win32 [nd]make builds the 'static' target when ALL_STATIC=define

10 years agoStop (?[]) operators from leaking
Father Chrysostomos [Thu, 6 Jun 2013 15:47:31 +0000 (08:47 -0700)]
Stop (?[]) operators from leaking

When a (?[]) extended charclass is compiled, the various operands are
stored as inversion lists in separate SVs and then combined together
into new inversion lists.  The functions that take care of combining
inversion lists only ever free one operand, and sometimes free none.
Most of the operators in (?[]) were trusting the invlist functions to
free everything that was no longer needed, causing (?[]) compilation
to leak invlists.

10 years agoperldiag: Document ‘Expecting '(?flags:(?[...'’
Father Chrysostomos [Thu, 6 Jun 2013 15:17:44 +0000 (08:17 -0700)]
perldiag: Document ‘Expecting '(?flags:(?[...'’

10 years agoperldiag: Clarify why ‘False [] range’ can be F
Father Chrysostomos [Thu, 6 Jun 2013 13:22:45 +0000 (06:22 -0700)]
perldiag: Clarify why ‘False [] range’ can be F

10 years agoMerge remote-tracking branch 'remotes/origin/smoke-me/env-instead-of-echo' into blead
H.Merijn Brand [Thu, 6 Jun 2013 14:18:44 +0000 (16:18 +0200)]
Merge remote-tracking branch 'remotes/origin/smoke-me/env-instead-of-echo' into blead

10 years agoperldiag: Correct severity/category for ‘False [] range’
Father Chrysostomos [Thu, 6 Jun 2013 06:56:52 +0000 (23:56 -0700)]
perldiag: Correct severity/category for ‘False [] range’

This can now be a fatal error or a warning.  diag.t is still not
smart enough to verify this, so it is still in its exception list.

10 years agodiag.t: Don’t confuse the two exception listse
Father Chrysostomos [Thu, 6 Jun 2013 06:44:05 +0000 (23:44 -0700)]
diag.t: Don’t confuse the two exception listse

The second exception list is for things listed in perldiag whose cate-
gories are in need of correction or are too baffling for diag.t to
check correctly (it’s not very smart).

Due to my careless implementation in commit 62f5f54d, the second list
was also treated effectively as an addendum to the first.  Things not
listed in perldiag could be listed in the second exception list and
make tests pass.

10 years agodiag.t: Remove commented obsoleted by 62f5f54dc2d
Father Chrysostomos [Thu, 6 Jun 2013 06:33:35 +0000 (23:33 -0700)]
diag.t: Remove commented obsoleted by 62f5f54dc2d

10 years agoAlphabetize perltrap
Father Chrysostomos [Thu, 6 Jun 2013 05:05:20 +0000 (22:05 -0700)]
Alphabetize perltrap

Before 9b12f83b0b6, the programming languages other than Perl were in
alphabetical order.

10 years agoIn regcomp.c, Set_Node_Cur_Length() uses parse_start, so explicitly pass it.
Nicholas Clark [Wed, 5 Jun 2013 10:15:57 +0000 (12:15 +0200)]
In regcomp.c, Set_Node_Cur_Length() uses parse_start, so explicitly pass it.

The macro Set_Node_Cur_Length() had been referring to the variable
parse_start within its body. This somewhat secret reference is potentially
risky, as it was always taking a parameter node, hence one might assume that
that was all that it used, and change the value stored in parse_start.
(Specifically, one place that assigns RExC_parse - 1 to parse_start, and later
uses parse_start + 1, which looks like an obvious cleanup candidate)

So make parse_start an explicit parameter.

Also, eliminate the never-used macro Set_Cur_Node_Length. This was added as
part of commit fac927409d5ddf11 (April 2001) but never used.

10 years agoIn S_regatom, declare parse_start when RE_TRACK_PATTERN_OFFSETS is defined.
Nicholas Clark [Tue, 4 Jun 2013 15:37:10 +0000 (17:37 +0200)]
In S_regatom, declare parse_start when RE_TRACK_PATTERN_OFFSETS is defined.

Commit 779fedd7c3021f01 (March 2013) moved code which unconditionally used
parse_start into another block. Hence the variable is now only needed when
RE_TRACK_PATTERN_OFFSETS is defined, so wrap its declaration in #ifdef/#endif
to avoid C compiler warnings.

10 years agoDon’t leak the /(?[])/ parsing stack on error
Father Chrysostomos [Thu, 6 Jun 2013 04:40:24 +0000 (21:40 -0700)]
Don’t leak the /(?[])/ parsing stack on error

Instead of creating the parsing stack and then freeing it after pars-
ing the (?[...]) construct (leaking it whenever one of the various
errors scattered throughout the parsing code occurs), mortalise it to
begin with and let the mortals stack take care of it.