From: ptchristendom at yahoo dot com Operating system: Win XP Pro PHP version: 4CVS-2003-06-05 (stable) PHP Bug Type: Unknown/Other Function Bug description: mt_rand() returns 1898087491 too often
The function mt_rand() has a "preference" for the value 1898087491 for a majority (but not all) of the default seedings. As a result, if you don't seed it you will generate far too many collisions on the value 1898087491. If you seed it with values such as 0, 1, 2, 3, etc., the problem will not occur (these are all the seeds that I tried); however, the mt_rand should work properly when not seeded. Further, there SHOULD NOT be any single seed that causes this value to occur more than others. This leads me to believe that mt_rand() is not implemented correctly when not seeded. Here it says that it is not necessary to use mt_srand() to obtain "random" data: http://us3.php.net/manual/en/function.mt-srand.php --------------------------------------------------------- The following shows a test script that reproduces the problem: D:\php4-win32-STABLE-200306052030>type unseeded2.php <? for ($i = 0; $i < 25; $i++) print `php -q unseeded.php`."\n"; ?> D:\php4-win32-STABLE-200306052030>type unseeded.php <? $j = 0; for ($i = 0; $i < 65536; $i++) if (mt_rand() == 1898087491) $j++; print $j; ?> D:\php4-win32-STABLE-200306052030>php unseeded2.php Content-type: text/html X-Powered-By: PHP/4.3.3-dev 36480 39710 2308 41576 38524 39247 5005 5449 38011 29808 37577 5738 46785 42418 45619 42322 39296 15909 35019 39127 26830 37223 33348 22713 0 -- Edit bug report at http://bugs.php.net/?id=24050&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=24050&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=24050&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24050&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24050&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24050&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24050&r=support Expected behavior: http://bugs.php.net/fix.php?id=24050&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24050&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24050&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24050&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24050&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24050&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24050&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24050&r=gnused