pod/perlhacktips: Further info on glibc bug

Commit 6bfe0388956736a32b874cc5e31cc6437260b227 prompted me to do some
more digging.  The bug in glibc has apparently been fixed in 2.17.
cflags.SH: Fix a typo, cflags should be ccflags

This went undetected for the longest time since most flags are
irrelevant at this point, but is vital if you are using --sysroot.
Optimise out PUSHMARK/RETURN if return is the last statement in a sub.

This makes:

  sub baz { return $cat; }

Behave like:

  sub baz { $cat; }

Which is notably faster.

Unpatched:

  ./perl -Ilib/ ~/stuff/bench.pl
  Benchmark: timing 40000000 iterations of normal, ret...
    normal:  3 wallclock secs ( 1.60 usr +  0.01 sys =  1.61 CPU) @ 24844720.50/s (n=40000000)
       ret:  3 wallclock secs ( 2.08 usr +  0.00 sys =  2.08 CPU) @ 19230769.23/s (n=40000000)

Patched:

  ./perl -Ilib ~/stuff/bench.pl
  Benchmark: timing 40000000 iterations of aret, normal...
    normal:  2 wallclock secs ( 1.72 usr +  0.00 sys =  1.72 CPU) @ 23255813.95/s (n=40000000)
       ret:  2 wallclock secs ( 1.72 usr +  0.00 sys =  1.72 CPU) @ 23255813.95/s (n=40000000)

The difference in OP trees can be seen here:

Unpatched:

  $ perl  -MO=Concise,baz -e 'sub baz { return $cat }'
  main::baz:
  5  <1> leavesub[1 ref] K/REFC,1 ->(end)
  -     <@> lineseq KP ->5
  1        <;> nextstate(main 1 -e:1) v ->2
  4        <@> return K ->5
  2           <0> pushmark s ->3
  -           <1> ex-rv2sv sK/1 ->4
  3              <#> gvsv[*cat] s ->4
  -e syntax OK

Patched:

  $ ./perl -Ilib  -MO=Concise,baz -e 'sub baz { return $cat }'
  main::baz:
  3  <1> leavesub[1 ref] K/REFC,1 ->(end)
  -     <@> lineseq KP ->3
  1        <;> nextstate(main 1 -e:1) v ->2
  -        <@> return K ->-
  -           <0> pushmark s ->2
  -           <1> ex-rv2sv sK/1 ->-
  2              <$> gvsv(*cat) s ->3
  -e syntax OK

(Includes some modifications from Steffen)
Explain how '--' works in command-line invocation.

Excerpted from 'man bash': GNU Bash-2.05b, 2002 July 15.

For: RT #120732, as requested by bulk88.
op.c: Factor out two identical yyerror calls
Fix ‘Can't declare null operation in "my"’

This message is very unhelpful.  This was brought up in
ticket #115688.
Tests for rpeep optimisations in e45d8982ae
Also optimise returning lists: 'return ($one, $two);'
[perl #72406] Bad read with do{} until CONST

According to the original bug report, ‘do{print("foobar");}until(1)}’
crashes.  In recent perls it doesn’t, partly because of the slab allo-
cator, partly because such crashes are naturally fleeting.

‘foo while bar’ and ‘foo until bar’ make their way through newLOOPOP,
which then usually calls S_new_logop, to create and AND or OR op with
special pointers that turn it into a loop.

Because S_new_logop knows about folding ‘$x if 1’ down to a simple $x,
and because ‘do{foo()} while 0’ should still execute the do block,
newLOOPOP skips the call to S_new_logop in that case.

Hence, it assumes that if it has seen a do block on its lhs, then
S_new_logop must return an AND or OR op.

‘foo until bar’ is actually changed early on (in perly.y) to ‘foo
while !bar’, before it reaches newLOOPOP.  Constant folding usually
folds !1 down to a simple ""/0 (actually &PL_sv_no), so newLOOPOP sees
‘foo while 0’ for ‘foo until 1’.

If constant folding fails (e.g., because the parser has seen an
unmatched } and constant folding is skipped after such errors), then
newLOOPOP will see the unfolded !1.

S_new_logop has a special optimisation that changes ‘!foo && bar’ to
‘foo || bar’, etc.

That optimisation allows it to ‘see through’ the unoptimised !1 (a NOT
with a CONST kid) and get to the constant, folding the resulting op
and returning something that newLOOPOP is not expecting to be folded.
In the case of ‘do{print("foobar");}until(1)}’, it optimises the do
block away, which is wrong.

So newLOOPOP reads past the end of the op in this line:

	o->op_next = ((LOGOP*)cUNOPo->op_first)->op_other;

because it is treating an SVOP as a LOGOP.

I can trigger this condition by defeating constant folding some other
way.  Croaking in boolean overloading, but just the first time, will
do that, and crashes with blead:

{ package o; use overload bool => sub { die unless $::ok++; return 1 } }
use constant OK => bless [], o::;
do{print("foobar");}until OK;
__END__
Bus error: 10

My reading of the source code leads me to believe that this bad read
has been present since perl 5.000.  But back then it was not possible
to trigger it with this particular test case involving fatal overload-
ing (as of b7f7fd0bb it seems*), but ‘do{print("foobar");}until(1)}’
would have triggered it.

* Thanks to Matthew Horsfall for finding it.
fix format string warnings in regcomp.c
Make tests work with detached git dir

In my jenkins replacement, I run all tests with .git outside the work tree,
pointed to by $GIT_DIR. This is fairly common git practice, so let's make the
testsuite support this and run the relevant porting tests that are skipped
without this patch.
perldelta for 6b44ec6808
[perl #120752] Fix t/op/coreamp.t rand test

The way it was written it would even accept an empty string as
valid output.
Add Dabrien Murphy to AUTHORS
Get optree_samples.t passing when PERL_UNICODE is set

The testing infrastructure knows to strip out the ‘open’ hints when
they do not apply.
PATCH: [perl #120799] 5.18 regression with [:^ascii] and \x80-\xFF

Posix classes generally match different sets of characters under /d
rules than otherwise.  This isn't true for [:ascii:], but the handling
for it is shared with the others, so it needs to use the same mechanism
to deal with that.  I forgot this in commit
bb9ee97444732c84b33c2f2432aa28e52e4651dc which created this regression.

Our tests for this only use regexes with a single element, and an
optimization added in 5.18 causes this bug to be bypassed.  These tests
should be enhanced to force both code paths, but not for this commit,
which should be suitable for a maintenance release.
regcomp.c: Add comment
Add comments that re tests can be commented in col 7
Fix reference to chmod portability in chown
make base.pm more strict about nonexistent module check