|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-11-12 19:37 UTC] cataphract@php.net
[2010-11-12 19:38 UTC] cataphract@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: cataphract
[2010-11-12 19:38 UTC] cataphract@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 09 04:00:01 2025 UTC |
Description: ------------ in source file php/win32/time.c in function PHPAPI int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info) toward end (L108 in 5.3.3 sources) there is this block of code: if (time_Info->tv_usec > 1000000) { time_Info->tv_usec -= 1000000; ++time_Info->tv_sec; } Doing >= would be more correct, like this: if (time_Info->tv_usec >= 1000000) { time_Info->tv_usec -= 1000000; ++time_Info->tv_sec; } (for most of the gettimeofday usage this is very minor bug, but while profiling with xdebug extension on windows platform this does expose the xdebug bug http://bugs.xdebug.org/view.php?id=357 which together leads to garbage profiling results) Attached script does expose the problem also trough PHP (it fails at my machine quite regularly, shouldn't take more then 2-3 runs to catch it). Test script: --------------- <?php $safety_counter = 0; do { $t = gettimeofday(); } while( $t['usec'] < 1000000 && $safety_counter++ < 1000000 ); if ( $t['usec'] == 1000000 ) { echo '<pre>', print_r( $t, TRUE ), '</pre>'; die('Returned gettimeofday array contains 1mil+ of microseconds (which is 1second)!'); } echo 'The gettimeofday didn\'t produce wrong value (tried it 1mil times). Try again!'; ?> Expected result: ---------------- The returned $t['usec'] should never contain value >= 1000000, so the script should always end with final echo. Actual result: -------------- $t['usec'] == 1000000 occasionally (on my machine at least once per 5 runs of script).