#34832 [NEW]: sprintf not reentrant

From: Date: Tue, 11 Oct 2005 15:31:42 +0000
Subject: #34832 [NEW]: sprintf not reentrant
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-86413@lists.php.net to get a copy of this message
From: dolecek at stringdata dot cz Operating system: Windows 2000 PHP version: 5.0.5 PHP Bug Type: Reproducible crash Bug description: sprintf not reentrant Description: ------------ I'm using PHP with Apache 1.3.23 via apache module, using windows PHP binaries downloaded from php.net. If several parallelly running scripts execute same blocks of code using sprintf("%.2f", $somefloat*$otherfloat), occassionally incorrect float number is printed or even one character of the "float" contains binary NUL. Easy way to trigger this is to have a FPDF script generating a PDF document, and have something which calls this script via web request in parallel, so that all scripts are executed within the context of single web server process. The problem appears in about 1% of generated documents. The problem is repeatably in my environment, I can try to put together simplier version of reproducing script if need be. If I replace the above contruct with number_format($somefloat*$otherfloat, 2, '.', ''), it works without problem and no problem occurs. The length of the gardbled output always exactly matches the length of non-gardbled output, FWIW. This suggests there is some kind of reentrancy problem with the sprintf() routine, at least when printing floats. Perhaps some stack alignment issue or something equally esoteric? The problem exists in 5.1b3, 5.1.0rc1, 5.0.5. I did not check other versions. The type of bug has been set to repoducible crash due to missing 'Memory corruption' category and since this _might_ cause a crash (tho no crash has been observed) - feel free to change to anything more appropriate if need be. Bug #21659 might actually be same problem, tho #21659 has been shrugged off as miscompilation problem. -- Edit bug report at http://bugs.php.net/?id=34832&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34832&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34832&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34832&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=34832&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=34832&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=34832&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=34832&r=needscript Try newer version: http://bugs.php.net/fix.php?id=34832&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=34832&r=support Expected behavior: http://bugs.php.net/fix.php?id=34832&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=34832&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=34832&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=34832&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34832&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=34832&r=dst IIS Stability: http://bugs.php.net/fix.php?id=34832&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=34832&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=34832&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=34832&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=34832&r=mysqlcfg

« previous php.bugs (#86413) next »