Skip Menu |

This queue is for tickets about the random CPAN distribution.

Report information
The Basics
Id: 50429
Status: open
Priority: 0/
Queue: random

People
Owner: Nobody in particular
Requestors: vladimir.vorontsov [...] onsec.ru
Cc:
AdminCc:

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



The same bug with rand(10000000) function call who returned only 32768 various values. See that http://bugs.activestate.com/show_bug.cgi?id=84937 Describe the bug: rand(10000000) generate only 32768 various results. Steps to reproduce this bug: 1. generate .pl script like that: #!/usr/bin/perl #12-10-2009 13-02 while (1){ if (time() eq "1255338173"){ last; }else { #print(time()."\n"); } } $tm=time(); while ($tm eq time()) { print (rand(10000000)."\n"); } 2. Set your system time to 12-10-2009 13-02 and run .pl script with redirect output stream to file. (C:\Straw-Perl\bin\perl.exe test.pl >> C:\perl-rand\output.txt) 3. Count various results in output file. If you doubt repeat step 2. Tested on Active Perl 1006, 638 and v5.10.0 built for MSWin32-x86-multi- thread, Strawberry Perl v5.10.0 built for MSWin32-x86-multi-thread (Filename strawberry-perl-5.10.0.6.msi) !Cygwin perl is correct! -- Best regards! Vladimir Vorontsov ONsec.ru:turn on security. Russian security team. http://onsec.ru
Subject: out-rand-undub.txt

Message body is not shown because it is too large.

Moreover, the result does not depend on time! The result depends only on the argument of the function rand(). For different arguments are different values, but for every argument, only 32,768 options! Run that (required cygwin): #!/usr/bin/perl $tries=10000000; $head="activeperl"; for $base (10000000, 1000000, 100000, 10000, 1000, 100, 10, 1){ $count = $tries; open (DATAFILE, ">> C:/rand/results/".$head."-rand-". $base."-".".txt"); while ( $count gt 0) { print DATAFILE (rand($base)."\n"); $count--; } $various=0; system("C:/cygwin/bin/sort.exe -u C:/rand/results/".$head."- rand-".$base."-".".txt > C:/rand/results/".$head."-rand-".$base."- SORTED".".txt"); open(FILE, "< C:/rand/results/".$head."-rand-".$base."- SORTED".".txt") or die "can't open file"; $various++ while <FILE>; print("\t".$tries." calls \tgive ".$various." different values \t on function rand(".$base.") \n "); } -- Best regards! Vladimir Vorontsov ONsec.ru:turn on security. Russian security team. http://onsec.ru