This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
11 years agoAdd "buzzhash16" - a random hash function
Yves Orton [Sat, 24 Nov 2012 18:21:38 +0000 (19:21 +0100)]
Add "buzzhash16" - a random hash function

This is just a toy. Probably not worth using in production. But
interesting enough I thought I would include it.

The idea is to use the hash seed as a table of random 16 bit integers
whose values are what we hash depending on the character we read.

It is pretty fast, I have no idea how secure it is. It will probably
work really badly if the seed is crap. YMMV.

11 years agoStop sub decl redef warnings from leaking CVs
Father Chrysostomos [Sat, 24 Nov 2012 08:31:01 +0000 (00:31 -0800)]
Stop sub decl redef warnings from leaking CVs

When newMYSUB and newATTRSUB are called, PL_compcv has an unclaimed
reference count, so any code that croaks must decrement the reference
count or make arrangements for such to happen.

This commit applies only to redefinition warnings triggered by sub
declarations, like ‘sub foo {}’ and ‘my sub foo {}’.

11 years agoperldiag: Correct wording of ‘Using just the first char...’
Father Chrysostomos [Sat, 24 Nov 2012 08:24:25 +0000 (00:24 -0800)]
perldiag: Correct wording of ‘Using just the first char...’

11 years agoperldiag: Add cat to ‘Using just the first char...’
Father Chrysostomos [Sat, 24 Nov 2012 08:20:17 +0000 (00:20 -0800)]
perldiag: Add cat to ‘Using just the first char...’

11 years agoIncrease $feature::VERSION to 1.32
Father Chrysostomos [Sat, 24 Nov 2012 08:19:05 +0000 (00:19 -0800)]
Increase $feature::VERSION to 1.32

11 years agoWarn when declaring lexsubs, not when enabling them
Father Chrysostomos [Sat, 24 Nov 2012 08:10:15 +0000 (00:10 -0800)]
Warn when declaring lexsubs, not when enabling them

feature.pm has an ":all" tag.  So if we warn when lexical subs are
enabled, then ‘use feature ":all"’ will also warn.  That’s unkind.

Instead, warn when a lexical sub is declared via
‘my/our/state sub...’.

11 years agoop.c: Factor common ‘existing sub’ logic into static routine
Father Chrysostomos [Sat, 24 Nov 2012 07:47:05 +0000 (23:47 -0800)]
op.c: Factor common ‘existing sub’ logic into static routine

newMYSUB and newATTRSUB are very similar but differ in small ways
throughout.  This particular block of code is close enough it can be
moved into a separate static routine to avoid repetition.

11 years agoWarn by default for constant my sub redefinition
Father Chrysostomos [Sat, 24 Nov 2012 07:44:49 +0000 (23:44 -0800)]
Warn by default for constant my sub redefinition

I apparently never had this working and never tested it either.

I was checking whether the new sub was a constant, rather than the one
it was clobbering.

11 years agoPrevent double frees with lexical constants
Father Chrysostomos [Sat, 24 Nov 2012 07:32:55 +0000 (23:32 -0800)]
Prevent double frees with lexical constants

my sub foo() { 2 }

This produces a double free, because SAVEPADSVANDMORTALIZE causes the
reference count to go down on scope exit, and nothing was increment-
ing it to compensate.

11 years agoop.c:newATTRSUB: Change an if condition to an else
Father Chrysostomos [Sat, 24 Nov 2012 04:40:39 +0000 (20:40 -0800)]
op.c:newATTRSUB: Change an if condition to an else

In one spot we have if(blah blah balh) {...} followed by
if (<exactly the opposite>).  We can just change the second if to
an else, since the condition is not going to change here.

This brings newATTRSUB and newMYSUB slightly closer, allowing me
to factor some of it out into a static routine in the next commit.

11 years agoStop ignored :lvalue warning from leaking CVs
Father Chrysostomos [Sat, 24 Nov 2012 04:32:49 +0000 (20:32 -0800)]
Stop ignored :lvalue warning from leaking CVs

When newMYSUB and newATTRSUB are called, PL_compcv has an unclaimed
reference count, so any code that croaks must decrement the reference
count or make arrangements for such to happen.

11 years agoprevent memory exhaustion from hash attacks
Yves Orton [Sat, 24 Nov 2012 10:16:48 +0000 (11:16 +0100)]
prevent memory exhaustion from hash attacks

We do not want to resize the hash every time the bucket length is
too long. Nor do we want to pay the price of checking how long
the bucket length is when there is nothing we can do about it anyway.

11 years agoSvPVXtrue single eval->multiple eval
Daniel Dragan [Fri, 23 Nov 2012 21:15:04 +0000 (16:15 -0500)]
SvPVXtrue single eval->multiple eval

Make SvTRUE and SvPVXtrue smaller and faster in machine code on non GCC
compilers.

This commit implements my posts here,
http://www.nntp.perl.org/group/perl.perl5.porters/2012/11/msg195720.html
and in my commit message in commit 4cc783efe0 . SvPVXtrue was added in
commit 4bac9ae47b . No reason was given why SvPVXtrue is single eval, but
its only use is in multi eval SvTRUE. A non GCC compiler will write to
PL_Xpv and PL_Sv, and still keep the SV * and PV *s in a register for the
next operations/instructions. The writes to PL_Xpv and PL_Sv are needless.
The use of PL_Xpv and PL_Sv is self explanatory C lang wise. As said in the
ML post, this commit causes overall code bloat because of incorrect uses
of passing macro args that make calls (ERRSV for example) to SvTRUE. This
will have to be fixed in the future. All of the pp opcode funcs decrease
tiny bit in size after this commit. See the ML list post for details.

11 years agoStop toke.c:S_scan_const from leaking
Father Chrysostomos [Sat, 24 Nov 2012 01:54:09 +0000 (17:54 -0800)]
Stop toke.c:S_scan_const from leaking

Fatal warnings and errors can cause the string buffer used when
scanning a quote-like operator to leak.  This commit fixes it
by using the savestack.  There are still a few leaks from that
code path that are not fixed by this.

11 years agoprevent multiple evaluations of ERRSV
Daniel Dragan [Fri, 23 Nov 2012 04:37:29 +0000 (23:37 -0500)]
prevent multiple evaluations of ERRSV

Remove a large amount of machine code (~4KB for me) from funcs that use
ERRSV making Perl faster and smaller by preventing multiple evaluation.

ERRSV is a macro that contains GvSVn which eventually conditionally calls
Perl_gv_add_by_type. If a SvTRUE or any other multiple evaluation macro
is used on ERRSV, the expansion will, in asm have dozens of calls to
Perl_gv_add_by_type one for each test/deref of the SV in SvTRUE. A less
severe problem exists when multiple funcs (sv_set*) in a row call, each
with ERRSV as an arg. Its recalculated then, Perl_gv_add_by_type and all.
I think ERRSV macro got the func call in commit f5fa9033b8, Perl RT #70862.
Prior to that commit it would be pure derefs I think. Saving the SV* is
still better than looking into interp->gv->gp to get the SV * after each
func call.

I received no responses to
http://www.nntp.perl.org/group/perl.perl5.porters/2012/11/msg195724.html
explaining when the SV is replaced in PL_errgv, so took a conservative
view and assumed callbacks (with Perl stack/ENTER/LEAVE/eval_*/call_*)
can change it. I also assume ERRSV will never return null, this allows a
more efficiently version of SvTRUE to be used.

In Perl_newATTRSUB_flags a wasteful copy to C stack operation with the
string was removed, and a croak_notcontext to remove push instructions to
the stack.  I was not sure about the interaction between ERRSV and message
sv, I didn't change it to a more efficient (instruction wise, speed, idk)
format string combining of the not safe string and ERRSV in the croak call.
If such an optimization is done, a compiler potentially will put the not
safe string on the first, unconditionally, then check PL_in_eval, and
then jump to the croak call site, or eval ERRSV, push the SV on the C stack
then push the format string "%"SVf"%s". The C stack allocated const char
array came from commit e1ec3a884f .

In Perl_eval_pv, croak_on_error was checked first to not eval ERRSV unless
necessery. I was not sure about the side effects of using a more efficient
croak_sv instead of Perl_croak (null chars, utf8, etc) so I left a comment.
nocontext used to save an push instruction on implicit sys perl.

In S_doeval, don't open a new block to avoid large whitespace changes.
The NULL assignment should optimize away unless accidental usage of errsv
in the future happens through a code change. There might be a bug here from
commit ecad31f018 since previous a char * was derefed to check for null
char, but ERRSV will never be null, so "Unknown error\n" branch will never
be taken.

For pp_sys.c, in pp_die a new block was opened to not eval ERRSV if
"well-formed exception supplied". The else if else if else blocks all used
ERRSV, so a  "SV * errsv =  NULL;" and a eval in the conditional with comma
op thing wouldn't work (maybe it would, see toke.c comments later in this
message). pp_warn, I have no comments.

In S_compile_runtime_code, a croak_sv question comes up same as in
Perl_eval_pv.

In S_new_constant, a eval in the conditional is done to avoid evaling
ERRSV if PL_in_eval short circuits. Same thing in Perl_yyerror_pvn.

Perl__core_swash_init I have no comments.

In the future, a SvEMPTYSTRING macro should be considered (not fully
thought out by me) to replace the SvTRUEs with something smaller and
faster when dealing with ERRSV. _nomg is another thing to think about.

In S_init_main_stash there is an opportunity to prevent an extra ERRSV
between "sv_grow(ERRSV, 240);" and "CLEAR_ERRSV();" that was too complicated
for me to optimize.

before perl517.dll
.text 0xc2f77
.rdata 0x212dc
.data 0x3948

after perl517.dll
.text 0xc20d7
.rdata 0x212dc
.data 0x3948

Numbers are from VC 2003 x86 32 bit.

11 years agosv.c:S_curse: move assertions to make them useful
Father Chrysostomos [Fri, 23 Nov 2012 03:18:57 +0000 (19:18 -0800)]
sv.c:S_curse: move assertions to make them useful

I added these when debugging something, and decided to keep them, as
they could be useful.  So I committed them as 14eebc59.

But now I realise that they are quite useless where they are, as a
program will crash before the failed assertions are reached.

11 years agosv.c:S_curse: remove unnecessary null check
Father Chrysostomos [Thu, 22 Nov 2012 22:53:47 +0000 (14:53 -0800)]
sv.c:S_curse: remove unnecessary null check

If an SV has the OBJECT flag on but no STASH, it will cause crashes
elsewhere.  So there has to be a stash here.  I only put the null
check there in 8c34e50dc because I was copying what StashHANDLER
used to do.  8c34e50dc removed the use of StashHANDLER (which calls
gv_handler, which has a null check), replacing it with a different
caching mechanism inlined into S_curse.

11 years agosvleak.t: To-do tests for fatal warnings and some syntax errs
Father Chrysostomos [Thu, 22 Nov 2012 06:52:14 +0000 (22:52 -0800)]
svleak.t: To-do tests for fatal warnings and some syntax errs

11 years agoremove an EXTEND from XS_re_regexp_pattern
Daniel Dragan [Fri, 23 Nov 2012 08:57:41 +0000 (00:57 -0800)]
remove an EXTEND from XS_re_regexp_pattern

Replace 2 EXTENDs with 1. Whether the stack is extended by 1 or 2 makes
no signifigant memory difference, so use the large value of 2. Less
machine code is the purpose. This XSUB went from 0x1C2 long to 0x19E for me
after these changes on VC 2003 x86 32bit. The SP and items was moved so
items is tossed a tiny bit sooner by the compiler in case the compiler
tries to save it because it doesn't recogize noreturn declared funcs.

11 years agoSuperFastHash needs to define PERL_HASH_SEED_BYTES appropriately.
Nicholas Clark [Fri, 23 Nov 2012 13:29:05 +0000 (14:29 +0100)]
SuperFastHash needs to define PERL_HASH_SEED_BYTES appropriately.

11 years agoThe size of PL_hash_seed depends on the chosen hash algorithm.
Nicholas Clark [Fri, 23 Nov 2012 10:42:02 +0000 (11:42 +0100)]
The size of PL_hash_seed depends on the chosen hash algorithm.

For most 8 is fine, but SipHash needs 16.

11 years agoUpdate Unicode-Collate to CPAN version 0.94
Chris 'BinGOs' Williams [Fri, 23 Nov 2012 11:47:26 +0000 (11:47 +0000)]
Update Unicode-Collate to CPAN version 0.94

  [DELTA]

  0.94  Fri Nov 23 18:45:53 2012
    - U::C::Locale newly supports locale: zh__zhuyin.
    - added Unicode::Collate::CJK::Zhuyin for zh__zhuyin.
    - doc: added CAVEAT to CJK/Stroke.pm
    - modified tests: loc_cjk.t, loc_cjkc.t in t.
    - added cjk_zy.t, loc_zhzy.t in t.

11 years agoav_exists: dont make a mortal never to use it
bulk88 (via RT) [Fri, 23 Nov 2012 00:33:34 +0000 (16:33 -0800)]
av_exists: dont make a mortal never to use it

Make av_exists slightly smaller and faster by reducing the liveness of a
mortal SV and using a NN SvTRUE_nomg.

There were 3 cases, where this mortal would be created, yet a return
happened and the mortal went unused and was wasted. So move the mortal
creation point closer to where it is first used. Also var sv will never be
null, so use a NN version of SvTRUE_nomg created in commit [perl #115870].
The retbool line isn't actually required for optimization reasons, but was
created just in case something in the future changes or some unknown
compiler does something inefficiently.

For me with 32 bit x86 VC 2003, before av_exists was 0x1C2, after 0x1B8.

Comment from committer: Includes SvTRUE_nomg_NN from [perl #115870].

11 years agoFix typo in perl5120delta
l.mai@web.de [Fri, 23 Nov 2012 02:03:55 +0000 (18:03 -0800)]
Fix typo in perl5120delta

11 years agoReduce scope of SP in Perl_eval_pv
Daniel Dragan [Fri, 23 Nov 2012 07:02:18 +0000 (08:02 +0100)]
Reduce scope of SP in Perl_eval_pv

This commit has no effect on machine code, since dSP has no calls and
is removed as dead code by the compiler since SP is never read until after
the SPAGAIN. By reducing the scope of SP, accidentally lengthing SP's
liveness won't happen and also the code makes a little bit more sense than
the SPAGAIN which for a sec makes you think SVs were put on the Perl
stack before the eval_sv call. Clarity is the purpose.

11 years agoPreserve the case of t/lib/vmsfspec.t.
Craig A. Berry [Fri, 23 Nov 2012 03:55:31 +0000 (21:55 -0600)]
Preserve the case of t/lib/vmsfspec.t.

The way this file has been getting copied from vms/ext/filespec.t
during the build involves the expansion of the standard macro
MMS$TARGET, a process which caused the name of the copied file to
always end up in upper case.

Before we started preserving case, all filenames were downcased
by readdir(), so .t matched .t and everything was peachy. But
when we started preserving case in Perl on VMS we started silently
skipping this test because .T does not match the pattern we look
for in t/TEST.

So take advantage of the fact that MMS and MMK don't upcase
user-written macros when expanded and use one of those as the
copy target, thus preserving the case of the copied file, which
then matches what t/TEST is looking for.

11 years agopodcheck.t: Was always giving failure under -regen
Karl Williamson [Thu, 22 Nov 2012 15:48:59 +0000 (08:48 -0700)]
podcheck.t: Was always giving failure under -regen

The tests added in commit da33abaf8bbfaee9e713ac54f3355186650df952
should be skipped under -regen.  No tests should be run under -regen.

11 years agoUpdate with Module-CoreList-2.78
Chris 'BinGOs' Williams [Thu, 22 Nov 2012 11:05:06 +0000 (11:05 +0000)]
Update with Module-CoreList-2.78

11 years agoSkip the test for fork's undef return if ulimit -u doesn't work locally.
Nicholas Clark [Wed, 21 Nov 2012 15:12:57 +0000 (16:12 +0100)]
Skip the test for fork's undef return if ulimit -u doesn't work locally.

Commit af2fe5eb7afec48a added a test for fork returning undef on failure,
which used ulimit -u to lower the number of user processes to provoke fork
failure. Whilst the test was careful to ensure that it only attempted this
if the shell is bash or zsh, it turns out that one some platforms (at least
HP-UX and AIX), bash offers ulimit -u, but will always error if its use is
attempted. So probe that ulimit -u can be used, and skip the test if it
can't.

11 years agoBump $XS::Typemap::VERSION after previous commit.
Nicholas Clark [Thu, 22 Nov 2012 09:27:51 +0000 (10:27 +0100)]
Bump $XS::Typemap::VERSION after previous commit.

11 years agoAdd additional tests for T_BOOL typemap
Steffen Mueller [Thu, 22 Nov 2012 07:03:16 +0000 (08:03 +0100)]
Add additional tests for T_BOOL typemap

Unlike the existing tests, these new tests don't use RETVAL.

11 years agoBetter pass-through handling for tovmsspec.
Craig A. Berry [Thu, 22 Nov 2012 04:03:03 +0000 (22:03 -0600)]
Better pass-through handling for tovmsspec.

When translating filenames from Unix syntax to VMS syntax, there
are some unparseable cases that are best left unchanged.  We were
doing this with extended filename syntax turned off, but we still
need it even when extended filename syntax is turned on, such as
for unescaped extended characters in a name that has no directory
delimiters.

11 years agoprevious patch forgot to bump the version on Locale::Maketext for CPAN
Yves Orton [Wed, 21 Nov 2012 23:45:45 +0000 (00:45 +0100)]
previous patch forgot to bump the version on Locale::Maketext for CPAN

also updated Changelog

11 years agofix hash order dependency bug in Local-Maketext/t/09_compile.t
Yves Orton [Wed, 21 Nov 2012 23:43:14 +0000 (00:43 +0100)]
fix hash order dependency bug in Local-Maketext/t/09_compile.t

This would occasionally fail if it ended up encountering PERL5LIB in the environment hash
as the first value.

The test was actually broken anyway, as it would infinitie loop with a totally empty environment

11 years agoRemove improper use of each() in B::walksymtable and fix ext/B/t/xref.t
Yves Orton [Wed, 21 Nov 2012 22:45:24 +0000 (23:45 +0100)]
Remove improper use of each() in B::walksymtable and fix ext/B/t/xref.t

Improper use of each() in walksymtable() makes behavior undefined.

As of the hash randomization patch ext/B/t/xref.t would occasionally
fail. A closer inspection revealed that the output that is parsed
in t/xref.t would vary greatly from run to run, with bizarre double
entries and sometimes missing packages, etc. So in 100 runs we would see
something like 25 of one variant, and then 25 of another, and then about
50 singletons. The notable difference between the two large groups is
that one was missing entire modules worth of output, the other appeared
to be correct. The singletons tended to differ from one of the other
two by a line or two.

Changing the each() to a keys() appears to fix this bug, making the
output consistent every time. My theory is that it is possible for the
symbol table logic to recurse and enter the same package twice, which
would result in its each iterator changing state but I have not verfied
this.  In order to make sure that the traversal order is deterministic
I decided to use sort(keys()) (In other words the sort() is there to
guarantee a given output in the future, not to fix this bug).

Annoyingly many times the test would pass even though the output it was
parsing was grossly wrong. I think we need to figure out a better way to
test this module. We should probably check for the presence of various
packages, like the B package itsef, Errno.pm etc.

I cannot explain yet why this bug was sensitive to build options.
My normal build options seemed to not have any issue, wheras others did.

Apparently ok (with or without -Dusethreads):
    git clean -dfX; ./Configure -Doptimize=-g -d -Dusedevel -Dusethreads
        -Dprefix=~/bleadperl -Dcc=ccache\ gcc -Dld=gcc -DDEBUGGING

Regular fails:
    git clean -dfx; ./Configure -des -Dusedevel -Dprefix=~/bleadperl
        -Dcc=ccache\ gcc -Dld=gcc

My tests used the following one liners:

    for file in test{1..100}; do ./perl -Ilib ext/B/t/xref.t > $file 2>&1; done;
    md5sum test* | sort | uniq -c -w32 | sort -n

11 years agoregmatch(): silence OpenWatcom compiler warnings
David Mitchell [Wed, 21 Nov 2012 17:01:38 +0000 (17:01 +0000)]
regmatch(): silence OpenWatcom compiler warnings

There are two MULTICALL variables which are assigned to in one branch,
but not the other. The values of these variables are never used.
OpenWatcom complains about this, and the easiest way to shut it up may be
to assign null values in the other branch. As bulk88 pointed out, these
assignments should be optimised away anyway.

Based on a patch originally submitted by Reini Urban, but without
removing the PERL_UNUSED_VAR's required for gcc.

See the thread <50A2B8E5.5030401@gknw.net> for more info.

11 years agosv.c: Remove aTHX from croak_no_modify call
Father Chrysostomos [Wed, 21 Nov 2012 17:25:41 +0000 (09:25 -0800)]
sv.c: Remove aTHX from croak_no_modify call

This only applied to PERL_OLD_COPY_ON_WRITE.  Commit e3918bb703c
introduced this.  That commit was written before croak_no_modify
lost its aTHX, but was not merged till after that.  I missed this
when rebasing.

11 years agoFix double free with stashes blessed into each other
Father Chrysostomos [Wed, 21 Nov 2012 16:48:41 +0000 (08:48 -0800)]
Fix double free with stashes blessed into each other

When I added that extra pass in 5.16 that curses any remaining blessed
objects during global destruction, I caused this bug:

$ ./miniperl -e 'warn bless \%foo::, bar::; warn bless \%bar::, foo::'
bar=HASH(0x827260) at -e line 1.
foo=HASH(0x8272b0) at -e line 1.
Attempt to free unreferenced scalar: SV 0x8272b0, Perl interpreter: 0x800000 during global destruction.

By creating a circularity between stashes, with no RVs remaining, we
cause one of the two stashes, say foo, to be cursed during global
destruction.  That causes it to lower the remaining reference count
on bar, which, when freed, lowers its reference count on foo, which
then tries to lower its reference count on bar, which has already
been freed.

The solution here is to turn off the object flag before decrementing
the stash’s reference count.  So a recursive call won’t try to curse
the already accursed object.

Turning off the flag makes SvSTASH into a DESTROY cache.  That won’t
work if the SvREFCNT_dec call tries to access that cache.  So we have
to null the field before calling SvREFCNT_dec (which we should be
doing anyway).

11 years agorefactor pp_stringify and pp_and
Daniel Dragan [Tue, 20 Nov 2012 22:36:54 +0000 (17:36 -0500)]
refactor pp_stringify and pp_and

pp_stringify:

First, move all the SP/stack operations to before the first call in
pp_stringify (sv_copypv), this allows SP to never be saved across any calls.
SETTARG calls set magic, so that still has to be done. SETs does not ++/--
SP, so no need to do a PUTBACK. PL_op is read twice, once for TARG, once
for NORMAL. No point in caching it through the sv_copypv call since its not
worth saving a non-vol to C stack (x86) just to avoid 2 mem acesses. This
opcode now only has 2 vars saved across sv_copypv, my_perl and TARG.

pp_stringify dropped from 0x3F to 0x3C for me after these changes, 32 bit
x86 VC 2003.

pp_and:

Do the PERL_ASYNC_CHECK before anything else, calcing SP before
PERL_ASYNC_CHECK would mean saving it across the potential call. SvTRUE
macro checks its param for NULL. This SV * came off the Perl stack, it will
not be null since pp_and is not a core sub (see S_maybe_add_coresub) and
will not be called from pp_coreargs (pp_coreargs places (SV *)NULLs on
Perl stack). So create a SvTRUE_NN macro that does not check for NULL, this
saves a branch. Since the Perl stack is only touched twice, don't create
a local SP. See comment in code. This saves another variable to not be
saved across the sv_2bool_flags and removed PUTBACK instructions. PL_op is
only read once or twice (compiler choice) right before the 2 returns.
There is only 1 variable saved across any calls in pp_and now, and that is
my_perl. dSP also was not use to prevent an accidental use of a ++/-- SP
macro in pp_and in the future since there is no PUTBACK now. I guess for a
SPARC with register windowing and no direct memory instructions, accessing
PL_stack_sp twice will take more instructions 2 reads and a write to
PL_stack_sp vs 1 read and 1 write to PL_stack_sp with a dSP design. On
SPARC, with a register window, cross call regs have no cost per reg cost
aslong as you dont exceed their max number.

For me, pp_and went from 0x112 to 0xFF after this commit. Prior to dSP
removal, it was down to 0x109. SvTRUE_NN was named after SvREFCNT_inc_NN.
There remains an inefficiency in pp_and on non-GCC compilers due to
SvPVXtrue using PL_Xpv which will be dealt with in another commit.

11 years agofix a hash order dependency in cpan/List-Util tests
Yves Orton [Wed, 21 Nov 2012 08:45:06 +0000 (09:45 +0100)]
fix a hash order dependency in cpan/List-Util tests

cpan/List-Util/t/tainted.t fails if the environment variable
it access is PERL5LIB as that is set inside the process.

We filter out env vars starting with PERL and bump the version
numbers to 1.25_01.

11 years agoperlhack: better word
Father Chrysostomos [Wed, 21 Nov 2012 02:00:49 +0000 (18:00 -0800)]
perlhack: better word

At Aristotle’s suggestion

11 years agoAdd assertions to S_curse in sv.c
Father Chrysostomos [Tue, 20 Nov 2012 22:43:43 +0000 (14:43 -0800)]
Add assertions to S_curse in sv.c

If anything should go wrong with the order things are freed, we
could get crashes from this code.  The assertions seem like a
good idea.

11 years agoscope.c: Remove XXX tmp comment from SAVEt_FREEOP
Father Chrysostomos [Tue, 20 Nov 2012 22:32:37 +0000 (14:32 -0800)]
scope.c: Remove XXX tmp comment from SAVEt_FREEOP

This assertion helped me to find and fix a crashing bug, so I don’t
want it to be removed.

11 years agoRevert "Revert "8c34e50dc slowed down detruction with no DESTROY""
Father Chrysostomos [Tue, 20 Nov 2012 21:47:27 +0000 (13:47 -0800)]
Revert "Revert "8c34e50dc slowed down detruction with no DESTROY""

This reverts commit 95f9781bc2fad025553db0160ef9c2c5363312a1.

Now that the crash has been fixed by the preceding commit, we can
reinstate 7cc6787e9db.

11 years ago[perl #115830] Fix crash by not copying DESTROY cache
Father Chrysostomos [Wed, 21 Nov 2012 01:52:13 +0000 (17:52 -0800)]
[perl #115830] Fix crash by not copying DESTROY cache

See commits 8c34e50dc and 7cc6787e9db (the latter was reverted by
95f9781bc).

If we are going to store a DESTROY cache in SvSTASH when !SvOBJECT, we
have to make sure not to copy that cache, otherwise other threads will
try to call a CV in the first thread, resulting in a crash.

8c34e50dc introduced this bug, but the crash didn’t start happening
until 7cc6787e9db, and only on Windows.

11 years agosv.c: obsolete comment
Father Chrysostomos [Tue, 20 Nov 2012 21:42:10 +0000 (13:42 -0800)]
sv.c: obsolete comment

This was resolved by the addition of S_curse and do_curse.

11 years agoMention do_curse in alloc section of sv.c apidocs
Father Chrysostomos [Tue, 20 Nov 2012 21:40:54 +0000 (13:40 -0800)]
Mention do_curse in alloc section of sv.c apidocs

11 years agoFix panic/crash with sort { $not_num } and fatal warnings
Father Chrysostomos [Tue, 20 Nov 2012 20:28:57 +0000 (12:28 -0800)]
Fix panic/crash with sort { $not_num } and fatal warnings

I caused this in 5.15.4 in commit 1aa032b25ab:

$ ./miniperl -Ilib -e 'eval q|use warnings FATAL=>all=>; ()=sort{undef}1,2|'
panic: illegal pad in SAVEt_FREEOP: 0x803500[0x0] at -e line 1.

This panic only happens under debugging builds.

But it’s worse than that:

$ ./miniperl -Ilib -e 'eval { use warnings FATAL => all=>; ()=sort{undef}1,2}; my $x'
Bus error

It’s this piece of code in pp_sort.c that is the problem:

    pad = PL_curpad; PL_curpad = 0;
    if (PL_stack_sp != PL_stack_base + 1) {
assert(PL_stack_sp == PL_stack_base);
result = SvIV(&PL_sv_undef);
    }
    else result = SvIV(*PL_stack_sp);
    PL_curpad = pad;

If SvIV dies, then PL_curpad will never be restored.  That results in
a panic error when the string eval exits, under debugging builds, and
a crash for any subsequent pad ops, under any build.

So we need to use the savestack to protect PL_curpad.  To avoid the
overhead most of the time, we should do this only if the result is not
already a number.

Sorting with a sub that has a ($$) prototype follows a different
code path that contains the same logic, but it is safe in that case,
because sort with a sub already localises the pad.  I added tests for
it anyway.

11 years agoperldiag: Correct entry about sort sub and single values
Father Chrysostomos [Tue, 20 Nov 2012 17:56:15 +0000 (09:56 -0800)]
perldiag: Correct entry about sort sub and single values

Pure-Perl sort subroutines are always called in scalar context, so
it is not possible for them to return more or less than one item.

This entry implies that one would have to be careful about that
when writing a pure-Perl sort routine.

This only applies to XS sort routines, which *do* have to be
careful about that.

11 years agobump version to 5.17.7
Ricardo Signes [Wed, 21 Nov 2012 00:35:00 +0000 (19:35 -0500)]
bump version to 5.17.7

11 years agoadd perldelta for 5.17.7
Ricardo Signes [Wed, 21 Nov 2012 00:30:23 +0000 (19:30 -0500)]
add perldelta for 5.17.7

11 years agowrap some very long lines in verbatim blocks
Ricardo Signes [Wed, 21 Nov 2012 00:30:05 +0000 (19:30 -0500)]
wrap some very long lines in verbatim blocks

...I was sorely tempted to skip podcheck from looking at the
epigraphs file, mind you!

11 years agouse verbatim paragraphs for verse epigraphs
Ricardo Signes [Wed, 21 Nov 2012 00:16:35 +0000 (19:16 -0500)]
use verbatim paragraphs for verse epigraphs

...at least when I noticed the verse

11 years agoadd the v5.17.6 epigraph
Ricardo Signes [Wed, 21 Nov 2012 00:14:18 +0000 (19:14 -0500)]
add the v5.17.6 epigraph

11 years agoupdate perlhist and release schedule v5.17.6
Ricardo Signes [Tue, 20 Nov 2012 22:52:25 +0000 (17:52 -0500)]
update perlhist and release schedule

11 years agoupdate Module-CoreList
Ricardo Signes [Tue, 20 Nov 2012 22:49:29 +0000 (17:49 -0500)]
update Module-CoreList

11 years agoclean up and finalize the perldelta
Ricardo Signes [Tue, 20 Nov 2012 22:40:06 +0000 (17:40 -0500)]
clean up and finalize the perldelta

11 years agostart cleaning up perldelta for 5.17.6
Ricardo Signes [Mon, 19 Nov 2012 02:59:20 +0000 (21:59 -0500)]
start cleaning up perldelta for 5.17.6

11 years agoThe MurmurHash3 code can use the existing perl.h #defines for endianness.
Nicholas Clark [Tue, 20 Nov 2012 13:23:47 +0000 (14:23 +0100)]
The MurmurHash3 code can use the existing perl.h #defines for endianness.

The approach MurmurHash3 supplied wasn't able to probe endianness
successfully on (at least) HP-UX.

11 years agoperldelta.pod: Nits
Karl Williamson [Tue, 20 Nov 2012 16:59:28 +0000 (09:59 -0700)]
perldelta.pod: Nits

11 years agoperldelta for VMS case preservation features.
Craig A. Berry [Tue, 20 Nov 2012 13:11:36 +0000 (07:11 -0600)]
perldelta for VMS case preservation features.

11 years agoAdd perldelta for 517bb5c6f8
Steve Hay [Tue, 20 Nov 2012 08:27:17 +0000 (08:27 +0000)]
Add perldelta for 517bb5c6f8

11 years agorefine
Yves Orton [Tue, 20 Nov 2012 07:51:03 +0000 (08:51 +0100)]
refine

11 years agoadd more perldelta changes about hash patch
Yves Orton [Tue, 20 Nov 2012 07:39:36 +0000 (08:39 +0100)]
add more perldelta changes about hash patch

11 years agodocument hash changes in perldelta
Yves Orton [Tue, 20 Nov 2012 07:32:58 +0000 (08:32 +0100)]
document hash changes in perldelta

11 years agoperldelta: Entry for NO_TAINT_SUPPORT
Steffen Mueller [Tue, 20 Nov 2012 07:05:44 +0000 (08:05 +0100)]
perldelta: Entry for NO_TAINT_SUPPORT

11 years agoFix test-skipping logic for File::Find under no-taint-perl
Steffen Mueller [Mon, 19 Nov 2012 06:51:49 +0000 (07:51 +0100)]
Fix test-skipping logic for File::Find under no-taint-perl

11 years agopp_hot.c:padsv: rewrt cmnt for clrty
Father Chrysostomos [Tue, 20 Nov 2012 05:31:11 +0000 (21:31 -0800)]
pp_hot.c:padsv: rewrt cmnt for clrty

11 years agoRevert "8c34e50dc slowed down detruction with no DESTROY"
Father Chrysostomos [Tue, 20 Nov 2012 03:59:49 +0000 (19:59 -0800)]
Revert "8c34e50dc slowed down detruction with no DESTROY"

This reverts commit 7cc6787e9dbebdd83799d997361188ab6dfe8ead.

That commit is causing crashes on Windows for some as yet unknown rea-
son.  (See ticket #115830.)  I don’t have time to fix it before the
release of 5.17.6.

11 years agoperldiag: typo
Father Chrysostomos [Mon, 19 Nov 2012 20:32:02 +0000 (12:32 -0800)]
perldiag: typo

11 years agoembed.fnc: Fix flags problem for regposixcc
Karl Williamson [Tue, 20 Nov 2012 00:39:58 +0000 (17:39 -0700)]
embed.fnc: Fix flags problem for regposixcc

The static and inline flags are considered mutually exclusive.  This is
not a fatal embed error as something can't be inline unless it is also
static, but the warning is there because the entry looks suspicious.
Commit 2fd63cc5b615213574e0153ed2bf14d9df23c073 introduced the flags
that caused the warning

11 years agoregen/embed.pl: Fix uninit variable warning.
Karl Williamson [Tue, 20 Nov 2012 00:38:18 +0000 (17:38 -0700)]
regen/embed.pl: Fix uninit variable warning.

11 years agoMerge topic branch into blead
Karl Williamson [Tue, 20 Nov 2012 00:13:41 +0000 (17:13 -0700)]
Merge topic branch into blead

This branch continues to make more systematic the handy.h definitions of
isFOO() macros started in 53335a31ed2284e8aaf1b6bf1cdcc0c0357841d0,
fixing some bugs and some incidentals found along the way.

Four of these macros are changed to not use function calls for
characters outside the Latin1 range.  Three of these used interpreter
level variables.  All core uses of these three interpreter variables
are removed in this series of commits, so the variables could be removed
without affecting the core.

11 years agoRefactor is(SPACE|PSXSP)_(uni|utf8) macros and utf8.c
Karl Williamson [Mon, 19 Nov 2012 21:36:12 +0000 (14:36 -0700)]
Refactor is(SPACE|PSXSP)_(uni|utf8) macros and utf8.c

This refactors the isSPACE_uni, is_SPACE_utf8, isPSXSPC_uni,
and is_PSXSPC_utf8 macros in handy.h, so that no function call need be
done to handle above Latin1 input.  These macros are quite small, and
unlikely to grow over time, as Unicode has mostly finished adding white
space equivalents to the Standard.  The functions that implement these
in utf8.c are also changed to use the macros instead of generating a
swash.  This should speed things up slightly, with less memory used over
time as the swash fills.

11 years agoregexec.c: Use SPACE macros instead of swash
Karl Williamson [Mon, 19 Nov 2012 21:24:29 +0000 (14:24 -0700)]
regexec.c: Use SPACE macros instead of swash

This will avoid loading a swash when an above Latin1 code point is
tested to see if it matches \s.  The SPACE macro is quite small, and
unlikely to grow over time, as Unicode has mostly finished adding white
space equivalents to the Standard.

The CCC_TRY_U macro in regexec.c could not be used for this, and I just
expanded out what it would generate, modified to use the macro instead
of a swash.

11 years agoRefactor is_XDIGIT_uni(), is_XDIGIT_utf8() and macros
Karl Williamson [Mon, 19 Nov 2012 20:55:13 +0000 (13:55 -0700)]
Refactor is_XDIGIT_uni(), is_XDIGIT_utf8() and macros

This adds macros to regen/regcharclass.pl that are usable as part of the
is_XDIGIT_foo() macros in handy.h, so that no function call need be done
to handle above Latin1 input.  These macros are quite small, and
unlikely to grow over time.  The functions that implement these in
utf8.c are also changed to use the macros instead of generating a swash.
This should speed things up slightly, with less memory used over time as
the swash fills.

11 years agoRefactor is_BLANK_uni() and is_BLANK_utf8() macros
Karl Williamson [Mon, 19 Nov 2012 20:36:56 +0000 (13:36 -0700)]
Refactor is_BLANK_uni() and is_BLANK_utf8() macros

This adds macros to regen/regcharclass.pl that are usable as part of the
is_BLANK_foo() macros in handy.h, so that no function call need be done
to handle above Latin1 input.  These macros are quite small, and
unlikely to grow over time, as Unicode has mostly finished adding white
space equivalents to the Standard.  The functions that implement these
in utf8.c are also changed to use the macros instead of generating a
swash.  This should speed things up slightly, with less memory used over
time as the swash fills.

11 years agohandy.h: Add isVERTWS_uni(), isVERTWS_utf8()
Karl Williamson [Mon, 19 Nov 2012 20:14:24 +0000 (13:14 -0700)]
handy.h: Add isVERTWS_uni(), isVERTWS_utf8()

These two macros match the same things as \v does in patterns.  I'm
leaving them undocumented for now.

11 years agoRefactor is_CNTRL_utf8(), is_utf8_cntrl()
Karl Williamson [Mon, 19 Nov 2012 20:00:47 +0000 (13:00 -0700)]
Refactor is_CNTRL_utf8(), is_utf8_cntrl()

All controls will always be in the Latin1 range by Unicode's stability
policy.  This means that we don't have to call is_utf8_cntrl() when the
input to the is_CNTRL_utf8() macro is above Latin1; we can just fail.
And that means that Perl_is_utf8_cntrl() can just use the macro.

11 years agohandy.h: Refactor macros to avoid aTHX_ problems
Karl Williamson [Mon, 19 Nov 2012 19:08:26 +0000 (12:08 -0700)]
handy.h: Refactor macros to avoid aTHX_ problems

This refactors these macros so that other macros automatically add aTHX_
if necessary.

11 years agoembed.fnc: Make a function global
Karl Williamson [Mon, 19 Nov 2012 18:05:43 +0000 (11:05 -0700)]
embed.fnc: Make a function global

This function is supposed to only be called internally, but it is called
by a macro that has global scope, so it also has to be global.

11 years agoregexec.c: Add PERL_UNIUSED_VAR()
Karl Williamson [Mon, 19 Nov 2012 17:59:38 +0000 (10:59 -0700)]
regexec.c: Add PERL_UNIUSED_VAR()

This is an attempt to silence warnings on some compilers.

11 years agoXS-APItest/t/handy.t: Refactor
Karl Williamson [Mon, 19 Nov 2012 16:58:12 +0000 (09:58 -0700)]
XS-APItest/t/handy.t: Refactor

This takes advantage of the Unicode::UCD::prop_invlist() function,
introduced in 5.16, to replace the hard-coded tables of Unicode values
previously used  (and also relying on recent fixes to an undocumented
function from that module ).  It als changes to give better messages if
the evals fail.  Using prop_invlist() allows us to easily extend to all
tests testing of some non-Latin1 code points.

11 years agoUnicode::UCD.pm: Fix bugs in undocumented binary search function
Karl Williamson [Mon, 19 Nov 2012 17:06:41 +0000 (10:06 -0700)]
Unicode::UCD.pm: Fix bugs in undocumented binary search function

This function is undocumented mostly because I was afraid it would be
buggy, as many such implementations are.  See:
http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html
(I recommend reading that link; it is instructive, entertaining, and
humbling.)

And it turns out I was right that I was wrong (in my original code).  A
test was inexplicably reversed, and another missing.

11 years agoregen/regcharclass.pl: Add 'cp_high' macro type
Karl Williamson [Sat, 17 Nov 2012 03:13:33 +0000 (20:13 -0700)]
regen/regcharclass.pl: Add 'cp_high' macro type

This generates a macro whose code point parameter must be above Latin1.
It will be used in future commits to avoid redundant checks

11 years agoregcomp.c: Revise comment
Karl Williamson [Tue, 30 Oct 2012 03:31:17 +0000 (21:31 -0600)]
regcomp.c: Revise comment

11 years agoregexes: Add \v to table of latin1 char classes
Karl Williamson [Thu, 16 Aug 2012 03:45:05 +0000 (21:45 -0600)]
regexes: Add \v to table of latin1 char classes

This will be used in future commits to allow \v and \V to be treated
consistently with other character classes.  (Doing the same for \h isn't
necessary, as it matches identically to [:blank:] in the entire Unicode
range.)

11 years agoregcomp.h: Make some #defines sequential
Karl Williamson [Thu, 16 Aug 2012 03:32:30 +0000 (21:32 -0600)]
regcomp.h: Make some #defines sequential

ANYOF_MAX is used as the upper boundary in loops.  If we keep it larger
than necessary, the loop does extraneous iterations.

The #defines that come after ANYOF_MAX are moved down to start with it.
This is useful in a later commit that will create an entry in
l1_char_class_tab.h for vertical white space determination.

11 years agoregcomp.sym: Change regkind for NPOSIX regnodes
Karl Williamson [Sun, 12 Aug 2012 17:50:54 +0000 (11:50 -0600)]
regcomp.sym: Change regkind for NPOSIX regnodes

It turns out that it is more convenient for the complement of a node to
have a regkind that is also the complement of a node.  This creates
slight inconveniences that are included in this patch, but will help
further patches.

11 years agoregcomp: Change name of #define to better reflect its purpose
Karl Williamson [Thu, 16 Aug 2012 02:49:59 +0000 (20:49 -0600)]
regcomp: Change name of #define to better reflect its purpose

ANYOF_MAX is used for two different purposes; this separates them and
creates a separate #define for one of them.

11 years agoregcomp.c: Revise debugging function
Karl Williamson [Wed, 25 Jul 2012 02:28:48 +0000 (20:28 -0600)]
regcomp.c: Revise debugging function

I use this function for debugging, but it is normally commented out.
This commit adds an entry to embed.fnc for it that can quickly be
uncommented, and makes some revisions to the function itself.

11 years agohandy.h: white-space, comments only
Karl Williamson [Sat, 21 Jul 2012 19:15:01 +0000 (13:15 -0600)]
handy.h: white-space, comments only

11 years agohandy.h: Mark more clearly things for internal-only use
Karl Williamson [Sat, 21 Jul 2012 19:07:49 +0000 (13:07 -0600)]
handy.h: Mark more clearly things for internal-only use

This changes the names of some macros to begin with an underscore, and
changes comments to more clearly indicate things which aren't to be used
outside the Perl core.

11 years agohandy.h: Use class numbers instead of macros in macro generation
Karl Williamson [Sat, 21 Jul 2012 17:45:18 +0000 (11:45 -0600)]
handy.h: Use class numbers instead of macros in macro generation

This refactors the macro builder macros to accept a class number instead
of a macro name.  This is easier to understand than having to use
CAT2(), and it allows for a potential future commit to use these at
run-time, given a class number.

11 years agohandy.h: Convert 3 macros to standard form
Karl Williamson [Sat, 21 Jul 2012 14:50:29 +0000 (08:50 -0600)]
handy.h: Convert 3 macros to standard form

These three outliers don't have to be.  They can use the same
constructed form as the others surrounding them.  One requires a
temporary #define which will be removed in a future commit

11 years agohandy.h: Define some macros for consistency
Karl Williamson [Fri, 20 Jul 2012 18:57:27 +0000 (12:57 -0600)]
handy.h: Define some macros for consistency

isWORDCHAR_uni() and isWORDCHAR_utf8() are defined for consistency with
the other isWORDCHAR...() macros

The isALNUM_foo() versions are retained for backwards compatibility

11 years agoutf8.c: Request function to be inline
Karl Williamson [Fri, 7 Sep 2012 17:20:49 +0000 (11:20 -0600)]
utf8.c: Request function to be inline

This could remove a layer of function call overhead for this small
function, (if the compiler doesn't already choose to inline it).

11 years agoutf8.c: White-space, comments only
Karl Williamson [Fri, 7 Sep 2012 17:16:40 +0000 (11:16 -0600)]
utf8.c: White-space, comments only

11 years agoutf8.c: Fix potential bug
Karl Williamson [Fri, 7 Sep 2012 16:54:44 +0000 (10:54 -0600)]
utf8.c: Fix potential bug

Commit 87367d5f9dc9bbf7db1a6cf87820cea76571bf1a changed
core_invlist_init() to return not the swash, but the swash's inversion
list if small enough, allowing a faster binary search than a slower hash
look-up on small lists.  Calls to two functions that access swashes were
changed to make this transparent.  However, there are two more such
functions which were overlooked, and need to be upgraded to provide such
transparency, should they ever be called on swashes that have been
converted.  This commit fixes one of them, but leaves the other, with a
comment, as it's much harder to do, and will not ever likely be
called on such a swash (it is for internal core use only).

11 years agoembed.fnc: Restrict access to non-public functions
Karl Williamson [Fri, 16 Nov 2012 21:52:45 +0000 (14:52 -0700)]
embed.fnc: Restrict access to non-public functions

These two functions added earlier in 5.17 are not meant to be public.
This moves them so they are defined only for certain core files, and
marks them as experimental should they show up in any documentation.