From: RQuadling at GMail dot com Operating system: Windows XP SP3 PHP version: 5.3.0alpha2 PHP Bug Type: Math related Bug description: rand maxes out after a few calls.
Description: ------------ Hi. I was testing an encryption/decryption routine by passing it random lengths of random data. I realized that in a very short amount of time, all the strings being tested were the same length. I've reduced the string building code to the bare minimum. Reproduce code: --------------- <?php $i_Count = 0; // By the 6'th loop, we are stuck on 32767. while(++$i_Count <= 20) { $s_Data = ''; $j = rand(); for($i = 0 ; $i < $j ; ++$i) { $s_Data .= chr(rand(0, 255)); } echo $i_Count, ' ', $j, ' ', strlen($s_Data), "\n"; } Expected result: ---------------- 1 randomvalue1 randomvalue1 2 randomvalue2 randomvalue2 3 randomvalue3 randomvalue3 4 randomvalue4 randomvalue4 5 randomvalue5 randomvalue5 6 randomvalue6 randomvalue6 7 randomvalue7 randomvalue7 8 randomvalue8 randomvalue8 9 randomvalue9 randomvalue9 10 randomvalue10 randomvalue10 11 randomvalue11 randomvalue11 12 randomvalue12 randomvalue12 13 randomvalue13 randomvalue13 14 randomvalue14 randomvalue14 15 randomvalue15 randomvalue15 16 randomvalue16 randomvalue16 17 randomvalue17 randomvalue17 18 randomvalue18 randomvalue18 19 randomvalue19 randomvalue19 20 randomvalue20 randomvalue20 Actual result: -------------- 1 randomvalue1 randomvalue1 2 randomvalue2 randomvalue2 3 randomvalue3 randomvalue3 4 randomvalue4 randomvalue4 5 randomvalue5 randomvalue5 6 32767 32767 7 32767 32767 8 32767 32767 9 32767 32767 10 32767 32767 11 32767 32767 12 32767 32767 13 32767 32767 14 32767 32767 15 32767 32767 16 32767 32767 17 32767 32767 18 32767 32767 19 32767 32767 20 32767 32767 -- Edit bug report at http://bugs.php.net/?id=46097&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46097&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46097&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46097&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=46097&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=46097&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=46097&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=46097&r=needscript Try newer version: http://bugs.php.net/fix.php?id=46097&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=46097&r=support Expected behavior: http://bugs.php.net/fix.php?id=46097&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=46097&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=46097&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=46097&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46097&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=46097&r=dst IIS Stability: http://bugs.php.net/fix.php?id=46097&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=46097&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=46097&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=46097&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=46097&r=mysqlcfg