Skip Menu |

This queue is for tickets about the Math-Random-ISAAC CPAN distribution.

Report information
The Basics
Id: 90778
Status: new
Priority: 0/
Queue: Math-Random-ISAAC

People
Owner: Nobody in particular
Requestors: mabbuttg [...] yahoo.ca
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Re-seeding from random device throws warning
Date: Sun, 24 Nov 2013 11:40:34 -0800 (PST)
To: "bug-Math-Random-ISAAC [...] rt.cpan.org" <bug-Math-Random-ISAAC [...] rt.cpan.org>
From: Glenn Mabbutt <mabbuttg [...] yahoo.ca>
The documentation indicates the PRNG can be (effectively) re-seeded by calling "$rng=Math::Random::ISAAC->new(@seeds);" again. It also indicates the random device can be called to seed the PRNG. The initial seed from a random device (such as /dev/random or /dev/urandom) via "my $rng = Math::Random::ISAAC->new('/dev/urandom');" does not throw any warnings or errors. However, re-seeding the PRNG causes the following warning to appear after the program's execution: "Argument "/dev/urandom" isn't numeric in subroutine entry at /usr/local/share/perl5/Math/Random/ISAAC.pm line 35." As it displays after the program has executed, it is unclear if the re-seeding occurred correctly, or if the seed defaulted back to all zeroes as the documentation indicates happens if no seed is specified. So, in summary, the following program runs OK without errors or warnings: #!/usr/bin/perl use Math::Random::ISAAC; use strict; my $rng = Math::Random::ISAAC->new('/dev/urandom'); for (1..1000000) { print 'Result: ' . $rng->irand() . "\n"; } exit; The below runs, but throws the warning after execution: Argument "/dev/urandom" isn't numeric in subroutine entry at /usr/local/share/perl5/Math/Random/ISAAC.pm line 35. #!/usr/bin/perl use Math::Random::ISAAC; use strict; my $rng = Math::Random::ISAAC->new('/dev/urandom'); for (1..1000000) { if ($_ % 250000 == 0) { my $rng = Math::Random::ISAAC->new('/dev/urandom'); } print 'Result: ' . $rng->irand() . "\n"; } exit; The following work-around converts the output of /dev/urandom to integers (and then multiplies them together, which may not be necessary). No errors or warnings are thrown: #!/usr/bin/perl use Math::Random::ISAAC; use strict; my $rng = Math::Random::ISAAC->new('/dev/urandom'); for (1..1000000) { if ($_ % 250000 == 0) { my $seed1 = `od -vAn -N8 -tu8 < /dev/urandom`; my $seed2 = `od -vAn -N8 -tu8 < /dev/urandom`; my $seed3 = `od -vAn -N8 -tu8 < /dev/urandom`; my $seed4 = `od -vAn -N8 -tu8 < /dev/urandom`; my $seed = $seed1 * $seed2 * $seed3 * $seed4; $rng = Math::Random::ISAAC->new($seed); } print 'Result: ' . $rng->irand() . "\n"; } exit; Cheers.