This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Brian Fraser [Mon, 25 Mar 2013 04:46:43 +0000 (01:46 -0300)]
Silence "smartmatch is experimental" warnings in autodie
Brian Fraser [Tue, 26 Mar 2013 00:17:51 +0000 (21:17 -0300)]
perldelta for the new warnings
Brian Fraser [Mon, 25 Mar 2013 04:22:35 +0000 (01:22 -0300)]
Make smartmatch, given & when experimental
Brian Fraser [Mon, 25 Mar 2013 05:10:08 +0000 (02:10 -0300)]
t/porting/dual-life.t: Drop dependency on smartmatch
Brian Fraser [Sat, 23 Mar 2013 20:45:10 +0000 (17:45 -0300)]
t/re/regexp_unicode_prop.t: Drop dependency on given/when
Brian Fraser [Sat, 23 Mar 2013 20:42:34 +0000 (17:42 -0300)]
Porting/core-cpan-diff: Drop dependency on smartmatch
Brian Fraser [Sat, 23 Mar 2013 20:42:00 +0000 (17:42 -0300)]
Porting/checkpodencoding.pl: Drop dependency on smartmatch
Brian Fraser [Sat, 23 Mar 2013 20:40:54 +0000 (17:40 -0300)]
File::Glob: Drop dependency on given/when
Karl Williamson [Tue, 26 Mar 2013 19:30:02 +0000 (13:30 -0600)]
perlapi: Document some macros
Nicholas Clark [Mon, 25 Mar 2013 12:06:09 +0000 (13:06 +0100)]
xs_init() must pass a static char* when creating &DynaLoader::boot_DynaLoader.
newXS() assumes that the passed pointer to the filename is in static storage,
or otherwise will outlive the PVCV that it is about to create, and hence that
it's safe to copy the pointer, not the value, to CvFILE. Hence xs_init()
must not use an auto array to "store" the filename, as that will be on the
stack, and becomes invalid as soon as xs_init() returns. The analogous bug
fix was made in universal.c by commit
157e3fc8c802010d in Feb 2006.
Spotted by compiling for ithreads with gcc 4.8.0's ASAN and running
dist/B-Deparse/t/deparse.t
Nicholas Clark [Mon, 25 Mar 2013 10:56:40 +0000 (11:56 +0100)]
In In S_scan_heredoc(), avoid memNE() reading beyond the end of s.
If the heredoc terminator we are searching for is longer than the bytes
remaining in s, then the memNE() would read beyond initialised memory.
Hence change the loop bounds to avoid this case, and change the failure case
below to reflect the revised end-of-loop condition.
It doesn't matter that the loop no longer increments shared->herelines,
because the failure case calls S_missingterm(), which croaks.
Nicholas Clark [Mon, 25 Mar 2013 09:53:33 +0000 (10:53 +0100)]
In S_scan_heredoc(), the explicit test for '\n' duplicates the strNE().
PL_tokenbuf always starts with '\n', so a separate test of *s against '\n'
is duplicate work. Hence remove it, to make the code simpler and clearer.
Nicholas Clark [Mon, 25 Mar 2013 09:20:05 +0000 (10:20 +0100)]
PerlIO_find_layer should not be using memEQ() off the end of the layer name.
PerlIO_find_layer was using memEQ() to compare the name of the desired layer
with each layer in the array of known layers. However, it was always using
the length of the desired layer for the comparison, whatever the length of
the name it was comparing it with, resulting in out-of-bounds reads.
Craig A. Berry [Mon, 25 Mar 2013 01:49:38 +0000 (20:49 -0500)]
Copyright update for vms/vms.c.
Happy 20th Anniversary, Charles.
Craig A. Berry [Mon, 25 Mar 2013 01:39:38 +0000 (20:39 -0500)]
Make vms.c's Perl_flex_fstat preserve errno on success.
The CRTL's fstat() sets errno to EVMSERR and vaxc$errno to RMS$_IOP
when called on a proccess-permanent file (i.e., stdin, stdout, or
stderr). That error generally means a rewind operation on a file
that cannot be rewound. It's odd that fstat is doing such a thing,
but we can at least protect ourselves from the effects of it by
saving errno and restoring it on a successful call.
This cures a couple of test failures and TODOs in t/io/errno.t.
Craig A. Berry [Mon, 25 Mar 2013 01:31:59 +0000 (20:31 -0500)]
Revert "Restore errno after VMS hack in S_sv_gets_read_record."
This reverts commit
d46f021e36854e800770363f716e7b4a846102ef.
This can be done more universally (and from the point of view of
sv.c, less obtrusively) in Perl_flex_fstat in vms/vms.c.
Yves Orton [Sun, 24 Mar 2013 10:48:12 +0000 (11:48 +0100)]
improve how Devel::Peek::Dump handles iterator information
* If the hash is not OOK omit any iterator status information
instead of showing -1/NULL
* If the hash is OOK then add the RAND value from the iterator
and if the LASTRAND is not the same show it too
* Tweak tests to test the above.
Yves Orton [Sun, 24 Mar 2013 10:47:22 +0000 (11:47 +0100)]
Add a commented out warning and a way for diag.t to ignore it
Yves Orton [Sun, 24 Mar 2013 10:46:22 +0000 (11:46 +0100)]
improve iterator randomization
Max Maischein [Sun, 24 Mar 2013 10:35:43 +0000 (11:35 +0100)]
Add epigraph for 5.17.10
David Mitchell [Sat, 23 Mar 2013 23:08:59 +0000 (23:08 +0000)]
fix Peek.t to work with NEW COW
David Mitchell [Sat, 23 Mar 2013 23:05:18 +0000 (23:05 +0000)]
Revert "fix Peek.t to work with NEW COW"
This reverts commit
2b656fcc48f28912136698c28b3bd916c42d74f8.
I accidentally included the changes I was reviewing from a patch of
Reini's
David Mitchell [Sat, 23 Mar 2013 21:29:26 +0000 (21:29 +0000)]
regcomp.c: silence compiler warning
add a cast before doing a printf "%x" on a pointer
David Mitchell [Sat, 23 Mar 2013 21:17:01 +0000 (21:17 +0000)]
add descriptions to require.t test output
This is particularly important as in several places, the ok or not ok
message is generated in different ways depending on whether a require
successfully executed and printed "ok" for example.
David Mitchell [Sat, 23 Mar 2013 20:32:00 +0000 (20:32 +0000)]
fix Peek.t to work with NEW COW
Ricardo Signes [Sat, 23 Mar 2013 20:34:03 +0000 (16:34 -0400)]
fix a missed s/deprecated/experimental/ for my $_
Craig A. Berry [Sat, 23 Mar 2013 01:39:37 +0000 (20:39 -0500)]
Restore errno after VMS hack in S_sv_gets_read_record.
In
596a6cbd6bcaa8e6a4 I added a somewhat desperate hack to detect
if a file is record-oriented so that we preserve record semantics
when PL_rs has beeen set. I did it by calling fstat(), which is
already a pretty icky thing to be doing on every record read, but
it turns out things are even worse becaseu fstat() sets errno in
some conditions where it's successful, specifically when the file
is a Process-Permanent File (PPF), i.e., standard input or output.
So save errno before the fstat and restore it before doing the
read so if the read fails we get a proper errno. This gets
t/io/errno.t passing.
Side note: instead of fstat() here, we probably need to store a
pointer to the FAB (File Access Block) in the PerlIO struct so all
the metadata about the file is always accessible. This would
require setting up completion routines in PerlIOUnix_open and
PerlIOStdio_open.
Chris 'BinGOs' Williams [Fri, 22 Mar 2013 13:01:16 +0000 (13:01 +0000)]
constant is 1.27 on CPAN
Chris 'BinGOs' Williams [Fri, 22 Mar 2013 13:00:07 +0000 (13:00 +0000)]
Module-CoreList is 2.85 on CPAN
Max Maischein [Fri, 22 Mar 2013 09:42:10 +0000 (10:42 +0100)]
Bump version to5.17.11
Max Maischein [Fri, 22 Mar 2013 08:18:58 +0000 (09:18 +0100)]
New perldelta
Max Maischein [Fri, 22 Mar 2013 07:53:18 +0000 (08:53 +0100)]
Merge branch 'release-5.17.10' into blead
Max Maischein [Thu, 21 Mar 2013 21:06:38 +0000 (22:06 +0100)]
Remove empty POD sections, fix link in pod
Max Maischein [Thu, 21 Mar 2013 20:36:21 +0000 (21:36 +0100)]
add new release to perlhist
Max Maischein [Thu, 21 Mar 2013 20:29:32 +0000 (21:29 +0100)]
Update corelist for 5.17.10
Max Maischein [Thu, 21 Mar 2013 20:29:20 +0000 (21:29 +0100)]
Update perldelta for 5.17.10
Max Maischein [Thu, 21 Mar 2013 20:20:52 +0000 (21:20 +0100)]
Bump version number in INSTALL
Max Maischein [Thu, 21 Mar 2013 19:51:11 +0000 (20:51 +0100)]
Update Net::Ping from 2.40 to 2.41
This is necessary to make tests pass on Windows (XP and onward).
Patrik Hägglund [Sat, 2 Feb 2013 19:21:05 +0000 (20:21 +0100)]
PATCH [perl #106212] Add PL_perlio_mutex to atfork_lock/unlock
Using threads + fork() on Linux, and IO operations in the threads, the
PL_perlio_mutex may be left in a locked state at the call of fork(),
potentially leading to deadlock in the child process at subsequent IO
operations. (Threads are pre-empted and not continued in the child
process after the fork.)
Therefore, ensure that the PL_perlio_mutex is unlocked in the child
process, right after fork(), by using atfork_lock/unlock.
(The RT text gives ways to reproduce the problem, but are not easily
added to Perl's test suite)
Karl Williamson [Thu, 21 Mar 2013 18:02:38 +0000 (12:02 -0600)]
Add Patrik Hägglund to AUTHORS
Nicholas Clark [Thu, 21 Mar 2013 08:24:08 +0000 (09:24 +0100)]
Merge in the changes that deprecate the use of @*, &*, ** and %*.
Use of $* already generated a deprecation warning.
This resolves RT #116943.
Nicholas Clark [Wed, 20 Mar 2013 15:47:16 +0000 (16:47 +0100)]
Add a deprecation warning for all uses of @*, %*, &* and **.
All compile-time uses of the ** typeglob now warn.
Nicholas Clark [Wed, 20 Mar 2013 08:23:49 +0000 (09:23 +0100)]
Change the warning for $* to add ", and will become a syntax error".
The intent is that $*, @*, %*, &* and ** stop being parsed as punctuation
variables, freeing up the syntax for other use (possibly "splats").
Nicholas Clark [Wed, 20 Mar 2013 11:00:11 +0000 (12:00 +0100)]
Generate the deprecation warnings for all uses $* or $#.
Previously it would fail to be generated if another variable using the same
typeglob was seen first (e.g. @* before $*), and would not be generated for
the second and subsequent uses.
It's hard to fix the failure to generate warnings at all without also
generating them every time, and warning every time is consistent with the
warnings that $[ used to generate.
Nicholas Clark [Wed, 20 Mar 2013 10:40:42 +0000 (11:40 +0100)]
Additional tests for the deprecation warnings when using $* or $#.
Nicholas Clark [Wed, 20 Mar 2013 13:26:56 +0000 (14:26 +0100)]
Change tie_fetch_count.t to use *] instead of **.
The test is not sensitive to which typeglob is used.
Nicholas Clark [Wed, 20 Mar 2013 12:54:22 +0000 (13:54 +0100)]
Change B::Deparse's test to test interpolation of @] instead of @*.
The test wasn't specifically relying on @*, so any unused punctuation
variable is equally good. $] isn't going away any time soon, hence @] is
unlikely to change.
David Golden [Wed, 20 Mar 2013 21:14:21 +0000 (17:14 -0400)]
update Perl::OSType from 1.002 to 1.003
Nicholas Clark [Tue, 19 Mar 2013 19:18:30 +0000 (20:18 +0100)]
Re-order intrpvar.h to minimise holes in the interpreter struct.
Commit
19bc2726ec6be805 created 32 bytes of holes (on LP64 systems).
Brad Gilbert [Mon, 4 Mar 2013 18:36:56 +0000 (12:36 -0600)]
Make utf8 downgrading in constant.pm, version dependent
The reason for this change is that the test
that determines when to do this caused the
utf8 module to always be loaded.
Aaron Trevena [Wed, 20 Mar 2013 15:00:08 +0000 (09:00 -0600)]
I18N-Langinfo/Langinfo.pm: Pod nit
Karl Williamson [Wed, 20 Mar 2013 15:03:57 +0000 (09:03 -0600)]
Add Aaron Trevena to AUTHORS
Paul Green [Tue, 19 Mar 2013 03:43:25 +0000 (23:43 -0400)]
Ensure only DOSish builds force O_BINARY=1 in the open path
Paul Green [Sun, 17 Mar 2013 17:48:00 +0000 (13:48 -0400)]
Update copyright statement for the Stratus VOS port
Paul Green [Sun, 17 Mar 2013 17:47:10 +0000 (13:47 -0400)]
Update pod/perlpord.pod to reflect recent VOS port changes
Paul Green [Sun, 17 Mar 2013 17:46:18 +0000 (13:46 -0400)]
Update README.vos to reflect recent changes
Paul Green [Sun, 17 Mar 2013 15:41:51 +0000 (11:41 -0400)]
Update VOS hints file to use dynamic linking and 64-bit stream files
Paul Green [Sun, 17 Mar 2013 15:39:17 +0000 (11:39 -0400)]
Assume that the host and target have the same executable suffix
Paul Green [Sun, 17 Mar 2013 15:35:47 +0000 (11:35 -0400)]
Remove VOS floating-point workaround; VOS bug long since fixed
Shirakata Kentaro [Tue, 19 Mar 2013 20:23:12 +0000 (14:23 -0600)]
PATCH: [perl #117181] pod: nitpick
Karl Williamson [Tue, 19 Mar 2013 19:05:44 +0000 (13:05 -0600)]
pod/perlfunc: Tweak new kill() wording
I forgot to mention in an earlier commit message that the impetus and
some of the text for the original change in commit
1ac81c06ff5e50e413e5fe9197f48f1c986af8be came from Felipe Gasper.
I'm sorry.
Nicholas Clark [Tue, 19 Mar 2013 10:53:38 +0000 (11:53 +0100)]
Merge in the changes that remove setjmp() from regcomp.c
The code now uses regular returns instead of setjmp() and longjmp() for
signalling the need for pattern compilation to restart. By avoiding this,
and the corresponding need to mark many variables as volatile, we make
the code less fragile, and Address Sanitizer is now happy.
Nicholas Clark [Mon, 4 Feb 2013 16:54:33 +0000 (17:54 +0100)]
Document the uses of NULL returns in the regex parsing code.
Nicholas Clark [Mon, 21 Jan 2013 19:58:49 +0000 (20:58 +0100)]
Revert "PATCH: regex longjmp flaws"
This reverts commit
595598ee1f247e72e06e4cfbe0f98406015df5cc.
The netbsd - 5.0.2 compiler pointed out that the recent changes to add
longjmps to speed up some regex compilations can result in clobbering a
few values. These depend on the compiled code, and so didn't show up in
other compiler's warnings. This patch reinitializes them after a
longjmp.
[With a lot of hand editing in regcomp.c, to propagate the changes through
subsequent commits.]
Nicholas Clark [Mon, 21 Jan 2013 19:32:01 +0000 (20:32 +0100)]
In Perl_re_op_compile(), tidy up after removing setjmp().
Remove volatile qualifiers. Remove the variable jump_ret. Move the
initialisation of restudied back to the declaration. This reverts several of
the changes made by commits
5d51ce98fae3de07 and
bbd61b5ffb7621c2.
However, I can't see a cleaner way to avoid code duplication when restarting
the parse than to approach I've taken here - the label redo_first_pass is
now inside an if (0) block, which is clear but ugly.
Nicholas Clark [Mon, 21 Jan 2013 16:15:30 +0000 (17:15 +0100)]
Replace the longjmp()s in Perl_re_op_compile() with goto.
The regex parse needs to be restarted if it turns out that it should be done
as UTF-8, not bytes. Using setjmp()/longjmp() complicates compilation
considerably, causing warnings about missing use of volatile, and hitting
code generation errors from clang's ASAN. Using goto is much clearer.
Nicholas Clark [Sat, 19 Jan 2013 10:06:10 +0000 (11:06 +0100)]
Move the longjmp() that implements REQUIRE_UTF8 up to Perl_re_op_compile().
With longjmp() and setjmp() now in the same function (and all tests passing),
it becomes easy to replace the pair with a goto. Still evil, but "the lesser
of two evils".
Nicholas Clark [Fri, 18 Jan 2013 16:21:03 +0000 (17:21 +0100)]
Add a flag RESTART_UTF8 to the reg*() routines in regcomp.c
Add a flag RESTART_UTF8 along with infrastructure to the reg*() routines to
permit the parse to be restarted without using longjmp(). However, it's not
used yet.
Nicholas Clark [Fri, 18 Jan 2013 10:32:44 +0000 (11:32 +0100)]
In S_regclass(), create listsv as a mortal, claiming a reference if needed.
The SV listsv is sometimes stored in an array generated near the end of
S_regclass(). In other cases it is not used, and it needs to be freed if
any of the warnings that S_regclass() can trigger turn out to be fatal.
The simplest solution to this problem is to declare it from the start as a
mortal, and claim a (new) reference to it if it is *not* to be freed. This
permits the removal of all other code related to ensuring that it is freed
at the right time, but not freed prematurely if a call to a warning returns.
Nicholas Clark [Thu, 17 Jan 2013 10:47:13 +0000 (11:47 +0100)]
Document when and why S_reg{,branch,piece,atom,class}() return NULL.
As documented in pod/perlreguts.pod, the call graph for regex parsing
involves several levels of functions in regcomp.c, sometimes recursing more
than once.
The top level compiling function, S_reg(), calls S_regbranch() to parse each
single branch of an alternation. In turn, that calls S_regpiece() to parse
a simple pattern followed by quantifier, which calls S_regatom() to parse
that simple pattern. S_regatom() can call S_regclass() to handle classes,
but can also recurse into S_reg() to handle subpatterns and some other
constructions. Some other routines call call S_reg(), sometimes using an
alternative pattern that they generate dynamically to represent their input.
These routines all return a pointer to a regnode structure, and take a
pointer to an integer that holds flags, which is also used to return
information.
Historically, it has not been clear when and why they return NULL, and
whether the return value can be ignored. In particular, "Jumbo regexp patch"
(commit
c277df42229d99fe, from Nov 1997), added code with two calls from
S_reg() to S_regbranch(), one of which checks the return value and generates
a LONGJMP node if it returns NULL, the other of which is called in void
context, and so both ignores any return value, or the possibility that it is
NULL.
After some analysis I have untangled the possible return values from these
5 functions (and related functions which call S_reg()).
Starting from the top:
S_reg() will return NULL and set the flags to TRYAGAIN at the end of pragma-
like constructions that it handles. Otherwise, historically it would return
NULL if S_regbranch() returned NULL. In turn, S_regbranch() would return
NULL if S_regpiece() returned NULL without setting TRYAGAIN. If S_regpiece()
returns TRYAGAIN, S_regbranch() loops, and ultimately will not return NULL.
S_regpiece() returns NULL with TRYAGAIN if S_regatom() returns NULL with
TRYAGAIN, but (historically) if S_regatom() returns NULL without setting
the flags to TRYAGAIN, S_regpiece() would to. Where S_regatom() calls
S_reg() it has similar behaviour when passing back return values, although
often it is able to loop instead on getting a TRYAGAIN.
Which gets us back to S_reg(), which can only *generate* NULL in conjunction
with TRYAGAIN. NULL without TRYAGAIN could only be returned if a routine it
called generated it. All other functions that these call that return regnode
structures cannot return NULL. Hence
1) in the loop of functions called, there is no source for a return value of
NULL without the TRYAGAIN flag being set
2) a return value of NULL with TRYAGAIN set from an inner function does not
propagate out past S_regbranch()
Hence the only return values that most functions can generate are non-NULL,
or NULL with TRYAGAIN set, and as S_regbranch() catches these, it cannot
return NULL. The longest sequence of functions that can return NULL (with
TRYAGAIN set) is S_reg() -> S_regatom() -> S_regpiece() -> S_regbranch().
Rapidly returning right round the loop back to S_reg() is not possible.
Hence code added by commit
c277df42229d99fe to handle a NULL return from
S_regbranch(), along with some other code is dead.
I have replaced all unreachable code with FAIL()s that panic.
Nicholas Clark [Fri, 18 Jan 2013 15:30:39 +0000 (16:30 +0100)]
Return orig_emit from S_regclass() when ret_invlist is true.
The return value isn't used (yet). Previously the code was returning END,
which is a macro for the regnode number for "End of program" which happens to
be 0. It happens that 0 is valid C for a NULL pointer, but using it in this
way makes the intent unclear. Not only is orig_emit a valid type, it's
semantically the correct thing to return, as it's most recently added node.
Nicholas Clark [Wed, 16 Jan 2013 20:58:02 +0000 (21:58 +0100)]
Test that UTF-8 in the look-ahead of (?(?=...)...) restarts the sizing parse.
S_reg() recurses to itself to parse various constructions used as the
conditionals in conditional matching. Look-aheads and look-behinds can turn
out to need to be sized as UTF-8, which can cause the inner S_reg() to use
the macro REQUIRE_UTF8 is used to restart the parse. Test that this is
handled correctly.
Nicholas Clark [Wed, 16 Jan 2013 16:08:03 +0000 (17:08 +0100)]
Test that S_grok_bslash_N() copes if S_reg() restarts the sizing parse.
S_reg() can discover midway through parsing the pattern to determine its
size, that the pattern will actually need to be encoded as UTF-8. If
calculations so far have been done in terms of bytes, then the macro
REQUIRE_UTF8 is used to restart the parse, so that sizes can be calculated
correctly for UTF-8.
It is possible to trigger this restart when processing multi-character
charnames interpolated into the pattern using \N{}. Test that this is
handled correctly.
Nicholas Clark [Mon, 14 Jan 2013 08:46:48 +0000 (09:46 +0100)]
Remove unreachable duplicate (?#...) parsing code from S_reg()
I believe that this code was rendered unreachable when perl 5.001 added
code to S_nextchar() to skip over embedded comments. Adrian Enache noted
this in March 2003, and proposed a patch which removed it. See
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2003-03/msg00840.html
The patch wasn't applied at that time, and when he sent it again August,
he omitted that hunk. See
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2003-08/msg01820.html
That version was applied as commit
e994fd663a4d8acc.
Nicholas Clark [Wed, 16 Jan 2013 10:48:04 +0000 (11:48 +0100)]
Perl_sv_uni_display() needs to be aware of RX_WRAPPED()
Commit
8d919b0a35f2b57a changed the storage location of the string in
SVt_REGEXP. It updated most code to deal with this, but missed the use of
SvPVX_const() in Perl_sv_uni_display(). This breaks dumping regular
expressions which have the UTF-8 flag set.
Ricardo Signes [Tue, 19 Mar 2013 03:15:06 +0000 (23:15 -0400)]
perldelta for debugger changes
Ricardo Signes [Sat, 16 Mar 2013 17:42:28 +0000 (13:42 -0400)]
bump version on perl5db.pl
Kent Fredric [Wed, 13 Mar 2013 16:17:38 +0000 (05:17 +1300)]
lib/perl5db.pl: Workaround rt#116771 by putting DB::Obj inside BEGIN { }
Kent Fredric [Thu, 21 Feb 2013 09:44:04 +0000 (22:44 +1300)]
lib/perl5db.t: Add test for bug #116771, autotrace crashes debugger
Kent Fredric [Thu, 21 Feb 2013 09:41:48 +0000 (22:41 +1300)]
lib/perl5db.t: Add test for bug #116769, Frame=2 crashes debugger
Kent Fredric [Fri, 15 Feb 2013 10:24:56 +0000 (23:24 +1300)]
lib/perl5db.pl: refactor all calls to IO::Handle via ->autoflush to a short local function.
This hopefully resovles https://rt.perl.org/rt3/Ticket/Display.html?id=116769
and any issue similar to that which I may not have been unlucky enough
to fall upon.
Tony Cook [Mon, 18 Mar 2013 23:52:02 +0000 (10:52 +1100)]
bump Tie-File's test version to match the module version
Yves Orton [Sun, 17 Mar 2013 23:28:03 +0000 (00:28 +0100)]
detect each() after insert and produce warnings when we do
Inserting into a hash that is being traversed with each()
has always produced undefined behavior. With hash traversal
randomization this is more pronounced, and at the same
time relatively easy to spot. At the cost of an extra U32
in the xpvhv_aux structure we can detect that the xhv_rand
has changed and then produce a warning if it has.
It was suggested on IRC that this should produce a fatal
error, but I couldn't see a clean way to manage that with
"strict", it was much easier to create a "severe" (internal)
warning, which is enabled by default but suppressible with
C<no warnings "internal";> if people /really/ wanted.
Yves Orton [Sun, 17 Mar 2013 19:48:45 +0000 (20:48 +0100)]
ensure that inserting into a hash causes its hash iteration order to change
This serves two functions, it makes it harder for an attacker
to learn useful information by viewing the output of keys(),
and it makes "insert during traversal" errors much easier to
spot, as they will almost always produce degenerate behavior.
Yves Orton [Sun, 17 Mar 2013 19:33:19 +0000 (20:33 +0100)]
perturb insertion order and update xhv_rand during insertion and S_hsplit()
When inserting into a hash results in a collision the order of the items
in the bucket chain is predictable (FILO), and can be used to determine
that a collision has occured.
When a hash is too small for the number of items it holds we double
its size and remap the items as required. During this process the
keys in a bucket will reverse order, and exposes information to an
attacker that a collision has occured.
We therefore use the PL_hash_rand_bits() and the S_ptr_hash()
infrastructure to randomly "perturb" the order that colliding
items are inserted into the bucket chain. During insertion and
mapping instead of doing a simple "insert to top" we check the low
bit of PL_hash_rand_bits() and depending if it is set or not we
insert at the top of the chain, otherwise second from the top.
The end result being that the order in a bucket is less predictable,
which should make it harder for an attacker to spot a collision.
Every insert (via hv_common), and bucket doubling (via hsplit())
results in us updating PL_hash_rand_bits() using "randomish" data
like the hashed bucket address, the hash of the inserted item, and
the address of the inserted item.
This also updates the xhv_rand() of the hash, if there is one, during
S_hsplit() so that the iteration order changes when S_hsplit() is
called. This also is intended to make it harder for an attacker to
aquire information about collisions.
Yves Orton [Sun, 17 Mar 2013 19:19:09 +0000 (20:19 +0100)]
Harden hashes against hash seed discovery by randomizing hash iteration
Adds:
S_ptr_hash() - A new static function in hv.c which can be used to
hash a pointer or integer.
PL_hash_rand_bits - A new interpreter variable used as a cheap
provider of "semi-random" state for use by the hash infrastructure.
xpvhv_aux.xhv_rand - Used as a mask which is xored against the
xpvhv_aux.riter during iteration to randomize the order the actual
buckets are visited.
PL_hash_rand_bits is initialized as interpreter start from the random
hash seed, and then modified by "mixing in" the result of ptr_hash()
on the bucket array pointer in the hv (HvARRAY(hv)) every time
hv_auxinit() allocates a new iterator structure.
The net result is that every hash has its own iteration order, which
should make it much more difficult to determine what the current hash
seed is.
This required some test to be restructured, as they tested for something
that was not necessarily true, we never guaranteed that two hashes with
the same keys would produce the same key order, we merely promised that
using keys(), values(), or each() on the same hash, without any
insertions in between, would produce the same order of visiting the
key/values.
Yves Orton [Sun, 17 Mar 2013 14:20:20 +0000 (15:20 +0100)]
rework ROTL definitions (and add ROTL_UV)
Yves Orton [Tue, 12 Feb 2013 04:06:48 +0000 (05:06 +0100)]
default to PERL_FUNC_ONE_AT_A_TIME_HARD for all builds
For testing, but maybe for ever
Yves Orton [Tue, 11 Dec 2012 07:50:58 +0000 (08:50 +0100)]
silence signed mistmatch in comparison warning in Murmurhash
as far as I can tell 'i' can only be positive here.
Yves Orton [Mon, 10 Dec 2012 07:36:43 +0000 (08:36 +0100)]
add a hardened one-at-a-time hash variant
Mix in additional randomness into the final value.
Yves Orton [Sat, 8 Dec 2012 15:24:06 +0000 (16:24 +0100)]
Split out hash functions into new file and turn into inline static functions
This includes various tweaks related to building SipHash and other
cleanup.
Yves Orton [Tue, 11 Dec 2012 22:46:37 +0000 (23:46 +0100)]
add a "hash quality score" to Hash::Util::bucket_stats()
Yves Orton [Mon, 10 Dec 2012 08:43:59 +0000 (09:43 +0100)]
update ExtUtils-MakeMaker to github v6.65_01
Perl core specific highlights:
* Fix hash related issues for 5.18.
* Do not hard code the list of perl header files - discover them from disk instead
* Don't need completely different include file collector on VMS.
Lukas Mai [Fri, 15 Mar 2013 07:38:02 +0000 (08:38 +0100)]
emphasize signal names over numbers in kill() docs
Karl Williamson [Mon, 18 Mar 2013 01:53:46 +0000 (19:53 -0600)]
Add Felipe Gasper to AUTHORS
Karl Williamson [Mon, 18 Mar 2013 22:00:31 +0000 (16:00 -0600)]
dist/bignum/lib/bignum.pm: Fix broken pod link
Karl Williamson [Mon, 18 Mar 2013 21:53:49 +0000 (15:53 -0600)]
ext/Pod-Html/testdir/perlvar-copy.pod: Fix broken pod links
Karl Williamson [Mon, 18 Mar 2013 21:46:46 +0000 (15:46 -0600)]
dist/bignum/lib/bigrat.pm: Fix broken pod link
Karl Williamson [Mon, 18 Mar 2013 21:43:09 +0000 (15:43 -0600)]
dist/bignum/lib/bigint.pm: Fix broken pod link
Karl Williamson [Mon, 18 Mar 2013 21:37:33 +0000 (15:37 -0600)]
Math/BigRat.pm: Fix some broken pod links
This also changes the link to blog() to an internal one; it remains
broken, but should be documented in this pod, not outside it