summaryrefslogtreecommitdiff
path: root/t/porting
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2013-05-05 16:33:43 +0200
committerYves Orton <demerphq@gmail.com>2013-05-07 09:33:42 +0200
commit6a5b4183fb7901110d40b26a7e60b0950cc9465d (patch)
tree03097efff3b551cc07b262968b9a238f7cac6f6f /t/porting
parent64c33badc975262c1617c4756a5a7868443e14e8 (diff)
downloadperl-6a5b4183fb7901110d40b26a7e60b0950cc9465d.tar.gz
Make it possible to disable and control hash key traversal randomization
Adds support for PERL_PERTURB_KEYS environment variable, which in turn allows one to control the level of randomization applied to keys() and friends. When PERL_PERTURB_KEYS is 0 we will not randomize key order at all. The chance that keys() changes due to an insert will be the same as in previous perls, basically only when the bucket size is changed. When PERL_PERTURB_KEYS is 1 we will randomize keys in a non repeatedable way. The chance that keys() changes due to an insert will be very high. This is the most secure and default mode. When PERL_PERTURB_KEYS is 2 we will randomize keys in a repeatedable way. Repititive runs of the same program should produce the same output every time. The chance that keys changes due to an insert will be very high. This patch also makes PERL_HASH_SEED imply a non-default PERL_PERTURB_KEYS setting. Setting PERL_HASH_SEED=0 (exactly one 0) implies PERL_PERTURB_KEYS=0 (hash key randomization disabled), settng PERL_HASH_SEED to any other value, implies PERL_PERTURB_KEYS=2 (deterministic/repeatable hash key randomization). Specifying PERL_PERTURB_KEYS explicitly to a different level overrides this behavior. Includes changes to allow one to compile out various aspects of the patch. One can compile such that PERL_PERTURB_KEYS is not respected, or can compile without hash key traversal randomization at all. Note that support for these modes is incomplete, and currently a few tests will fail. Also includes a new subroutine in Hash::Util::hash_traversal_mask() which can be used to ensure a given hash produces a predictable key order (assuming the same hash seed is in effect). This sub acts as a getter and a setter. NOTE - this patch lacks tests, but I lack tuits to get them done quickly, so I am pushing this with the hope that others can add them afterwards.
Diffstat (limited to 't/porting')
-rw-r--r--t/porting/globvar.t15
-rw-r--r--t/porting/known_pod_issues.dat5
2 files changed, 15 insertions, 5 deletions
diff --git a/t/porting/globvar.t b/t/porting/globvar.t
index 795673b49a..fd169c7442 100644
--- a/t/porting/globvar.t
+++ b/t/porting/globvar.t
@@ -18,6 +18,9 @@ my %skip = map { ("PL_$_", 1) }
watchaddr watchok warn_uninit_sv
);
+$skip{PL_hash_rand_bits}= $skip{PL_hash_rand_bits_enabled}= 1; # we can be compiled without these, so skip testing them
+
+
my $trial = "nm globals$Config{_o} 2>&1";
my $yes = `$trial`;
@@ -57,13 +60,17 @@ foreach my $file (map {$_ . $Config{_o}} qw(globals regcomp)) {
close $fh or die "Problem running nm $file";
}
-fail("Attempting to export '$_' which is never defined")
- foreach sort keys %exported;
+foreach (sort keys %exported) {
+ SKIP: {
+ skip("We dont't export '$_' (Perl not built with this enabled?)",1) if $skip{$_};
+ fail("Attempting to export '$_' which is never defined");
+ }
+}
foreach (sort keys %unexported) {
SKIP: {
- skip("We don't export $_", 1) if $skip{$_};
- fail("$_ is defined, but we do not export it");
+ skip("We don't export '$_'", 1) if $skip{$_};
+ fail("'$_' is defined, but we do not export it");
}
}
diff --git a/t/porting/known_pod_issues.dat b/t/porting/known_pod_issues.dat
index 9e095712c9..6afa0495fa 100644
--- a/t/porting/known_pod_issues.dat
+++ b/t/porting/known_pod_issues.dat
@@ -105,6 +105,8 @@ PerlIO::via::Base64
PerlIO::via::StripHTML
perllexwarn(1)
perlthanks
+pod/perldiag.pod Verbatim line length including indents exceeds 79 by 1
+pod/perlrun.pod Verbatim line length including indents exceeds 79 by 3
POD2::FR
POD2::IT
pod2ipf(1)
@@ -223,6 +225,7 @@ pod/perldebguts.pod Verbatim line length including indents exceeds 79 by 34
pod/perldebtut.pod Verbatim line length including indents exceeds 79 by 22
pod/perldebug.pod Verbatim line length including indents exceeds 79 by 3
pod/perldiag.pod =item type mismatch 1
+pod/perldiag.pod Verbatim line length including indents exceeds 79 by 1
pod/perldsc.pod Verbatim line length including indents exceeds 79 by 4
pod/perldtrace.pod Verbatim line length including indents exceeds 79 by 26
pod/perlebcdic.pod Verbatim line length including indents exceeds 79 by 13
@@ -261,7 +264,7 @@ pod/perlpodstyle.pod Verbatim line length including indents exceeds 79 by 1
pod/perlref.pod Verbatim line length including indents exceeds 79 by 1
pod/perlrequick.pod Verbatim line length including indents exceeds 79 by 3
pod/perlretut.pod Verbatim line length including indents exceeds 79 by 13
-pod/perlrun.pod Verbatim line length including indents exceeds 79 by 2
+pod/perlrun.pod Verbatim line length including indents exceeds 79 by 3
pod/perlsolaris.pod Verbatim line length including indents exceeds 79 by 14
pod/perlsource.pod ? Should you be using F<...> or maybe L<...> instead of 1
pod/perlsub.pod ? Should you be using F<...> or maybe L<...> instead of 3