summaryrefslogtreecommitdiff
path: root/embed.fnc
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2022-03-06 09:42:14 +0100
committerYves Orton <demerphq@gmail.com>2022-03-10 03:22:33 +0100
commitc3c9d6b15f57fdce79988a553671a1ceb54c0f10 (patch)
treeedf6ddb1f711af36059bea8ec21790a0933d68a5 /embed.fnc
parent8a35994ac8fcc50aaed538b7625ba79635683630 (diff)
downloadperl-c3c9d6b15f57fdce79988a553671a1ceb54c0f10.tar.gz
hv.c - rework PL_hash_rand_bits update logic, add tests, -Dh debug mode
This moves all run time mutations of PL_hash_rand_bits into a set of macros which allow us to debug what is happening. It also moves away from our poor mans RNG based on mixing in various sources of data as we go and switches to using an XORSHIFT RNG for generating the random bits. This particular RNG is very efficient, using three xor operations and three shift operations, so it shouldn't hurt us to use it. As a bonus it also removes the conditional logic involved, as we use seed() to initialize things at the very beginning when we are running under RANDOMIZE mode, which should fix any problems with running on platforms that do not use process space randomization like cygwin. It adds support for -Dh under DEBUGGING to allow introspection of the the state of PL_hash_rand_bits and source and cause of changes to it. With -Dhv you can also get an idea of the keys which are triggering these mutations as well. -Dh has also been changed to imply PERL_HASH_SEED_DEBUG as a convenience. This goes alongside a new test, based on one from Nicholas R (atoomic) to test that the various PERL_PERTURB_KEYS options behave as expected and that 1 bit mutations of the seed actually *do* affect the key order and hashing of our strings. The test is run many times to ensure that it passes under many different randomly generated hash seeds. Parts of this test would fail without the preceding commit to this one adjusting how SBOX32 is initialized.
Diffstat (limited to 'embed.fnc')
-rw-r--r--embed.fnc3
1 files changed, 2 insertions, 1 deletions
diff --git a/embed.fnc b/embed.fnc
index 90d44b6bd1..12fb6fdc07 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -2649,7 +2649,8 @@ Ap |U32 |seed
XpTo |double |drand48_r |NN perl_drand48_t *random_state
XpTo |void |drand48_init_r |NN perl_drand48_t *random_state|U32 seed
: Only used in perl.c
-p |void |get_hash_seed |NN unsigned char * const seed_buffer
+p |void |get_hash_seed |NN unsigned char * const seed_buffer
+p |void |debug_hash_seed|bool via_debug_h
: Used in doio.c, pp_hot.c, pp_sys.c
p |void |report_evil_fh |NULLOK const GV *gv
: Used in doio.c, pp_hot.c, pp_sys.c