From: Kazeuri at Gmail dot com Operating system: SUSE 10 PHP version: 4.4.2 PHP Bug Type: Unknown/Other Function Bug description: rand and mt_rand BUG
Description: ------------ rand and mt_rand (which, no longer need to be seeded...) get stuck on the same "result" after a certain number of generations. I am unsure exactly why this is, and PLEASE, read in to this, its very easy at first to view this as a mistake, but according to all the documentation I have read, this should NOT occur. Reproduce code: --------------- header("Content-type: image/png"); $stext = "some text"; $x = 800; $y = 600; $im = @imagecreate($x, $y) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 0, 0, 0); $stnum = 0; while ($stnum <= 125){ $stize = rand(0,5); $xl = rand(0,800); $yl = rand(0,600); $text_color = imagecolorallocate($im, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255)); imagestring($im, $stize, $xl, $yl, $stext, $text_color); $stnum += 1; } imagepng($im); imagedestroy($im); Expected result: ---------------- An image with randomly generated text all over it in various places (random). Actual result: -------------- This works fine, for about 50 results or so, and then somehow, ALL THREE rand functions that contribute to the text color get "stuck" and one particular color begins to dominate (which changes randomly each time it is generated). -- Edit bug report at http://bugs.php.net/?id=37409&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37409&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37409&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37409&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37409&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37409&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37409&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37409&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37409&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37409&r=support Expected behavior: http://bugs.php.net/fix.php?id=37409&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37409&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37409&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37409&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37409&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37409&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37409&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37409&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37409&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37409&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37409&r=mysqlcfg