Skip to content

Commit e2481d4

Browse files
committed
Potential fix for PL_HASH_RAND_BITS_ENABLED == 2
References: Perl#250 It seems that the unit test `t/run/xrunenv.t` identifies an issue where we cannot reproduce a hash randomization when using the DETERMINISTIC mode. This is an attempt to fix it. Need review from upstream.
1 parent c644449 commit e2481d4

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

hv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
843843
* reset the iterator randomizer if there is one.
844844
*/
845845
in_collision = *oentry != NULL;
846-
if ( *oentry && PL_HASH_RAND_BITS_ENABLED) {
846+
if ( *oentry && PL_HASH_RAND_BITS_ENABLED == 1) {
847847
PL_hash_rand_bits++;
848848
PL_hash_rand_bits= ROTL_UV(PL_hash_rand_bits,1);
849849
if ( PL_hash_rand_bits & 1 ) {

t/run/xrunenv.t

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ sub runperl_and_capture {
6161
}
6262
}
6363

64-
our $TODO;
6564
SKIP:
6665
{
6766
#skip "NO_PERL_HASH_ENV or NO_PERL_HASH_SEED_DEBUG set", 16
@@ -81,13 +80,9 @@ SKIP:
8180
my($out2, $err2) = runperl_and_capture( { %base_opts, PERL_HASH_SEED => $seed }, [ @print_keys ]);
8281
if ( $mode eq 'RANDOM' ) {
8382
isnt ($out,$out2,"PERL_PERTURB_KEYS = $mode results in different key order with the same key");
84-
} elsif ( $mode eq 'NO' ) {
85-
is ($out,$out2,"PERL_PERTURB_KEYS = $mode allows one to recreate a random hash");
86-
} elsif ( $mode eq 'DETERMINISTIC' ) {
87-
local $TODO = q[need to check DETERMINISTIC mode];
83+
} else {
8884
is ($out,$out2,"PERL_PERTURB_KEYS = $mode allows one to recreate a random hash");
8985
}
90-
9186
is ($err,$err2,"Got the same debug output when we set PERL_HASH_SEED and PERL_PERTURB_KEYS");
9287
}
9388
}

0 commit comments

Comments
 (0)