develooper Front page | perl.perl5.changes | Postings from August 2022

[Perl/perl5] db0d35: t/op/each.t - Deal with env vars PERL_HASH_SEEDor...

Yves Orton via perl5-changes
August 6, 2022 20:26
[Perl/perl5] db0d35: t/op/each.t - Deal with env vars PERL_HASH_SEEDor...
Message ID:
  Branch: refs/heads/yves/consistent_srand
  Commit: db0d3504157b98e081d914b84e95cea4279a43e6
  Author: Yves Orton <>
  Date:   2022-08-06 (Sat, 06 Aug 2022)

  Changed paths:
    M t/op/each.t

  Log Message:
  t/op/each.t - Deal with env vars PERL_HASH_SEED or PERL_PERTURB_KEYS being set

This was the only test that fails if PERL_HASH_SEED=0 is in the env.
With this change this test will be run without any hash seed overrides
so it can test what it is intended to. This test will continue to fail
in certain build modes (fixed hash seed with no hash randomization
at all) and we should enhance this change in the future to skip the test
entirely when appropriate.

  Commit: 2b013c9fb4acbdd22c499150ea735e198b8526c8
  Author: Yves Orton <>
  Date:   2022-08-06 (Sat, 06 Aug 2022)

  Changed paths:
    M dist/threads/lib/
    A dist/threads/t/version.t

  Log Message:
  dist/threads - add a test to check that the pod version matches code

The code for setting $threads::VERSION specifically mentions the POD
needs to be kept in synch, but it is not in sync right now. :-(

This patch adds a test to validate the POD matches the code, and it
bumps the version so everything is happy.

  Commit: c93c14a255e4b281875efa34e0acfa240367b4da
  Author: Yves Orton <>
  Date:   2022-08-06 (Sat, 06 Aug 2022)

  Changed paths:
    M handy.h
    M hv.c

  Log Message:
  hv.c/handy.h - move logic from hv.c to handy.h

These mathematical/RNG functions are handy for various
internal uses, so expose them in a way they can be reused.

These are Marsaglia RNG "permutation" XORSHIFT triplets, from the famous
article he wrote on fast random number generation. By modern standards
they are only mediocre as far as RNGs go, but they still aren't bad. But
they are very fast, and have a few useful properties which can be handy
in places where we want a cheap source of pseudo random bits, or where
we want to get a random(ish) sequence of positive integers.

This will be used in a follow up patch.

  Commit: b539b9ff2043c78c32bfe9a1e835c993900dfddb
  Author: Yves Orton <>
  Date:   2022-08-06 (Sat, 06 Aug 2022)

  Changed paths:
    M dist/threads/t/thread.t
    M dist/threads/t/version.t
    M dist/threads/threads.xs
    M embedvar.h
    M handy.h
    M hv.c
    M intrpvar.h
    M perl.c
    M perl.h
    M pod/perldelta.pod
    M pod/perlfunc.pod
    M pod/perlrun.pod
    M pp.c
    M pp_sys.c
    M sv.c
    M t/op/srand.t
    A t/run/runenv_randseed.t

  Log Message:
  Add a new env var PERL_RAND_SEED

This env var can be used to trigger a repeatable run of a script which
calls C<srand()> with no arguments, either explicitly or implicitly
via use of C<rand()> prior to calling srand(). This is implemented in
such a way that calling C<srand()> with no arguments in forks or
subthreads (again explicitly or implicitly) will receive their own seed
but the seeds they receive will be repeatable.

This is intended for debugging and perl development performance testing,
and for running the test suite consistently. It is documented that the
exact seeds used to initialize the random state are unspecified, and
that they may change between releases or even builds. The only guarantee
provided is that the same perl executable will produce the same results
twice all other things being equal. In practice and in core testing we
do expect consistency, but adding the tightest set of restrictions on use
seemed sensible.

The env var is ignored when perl is run setuid or setgid similarly to

Compare: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About