php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64370 microtime(true) corrupted
Submitted: 2013-03-06 15:45 UTC Modified: 2013-03-15 18:19 UTC
From: bugzilla77 at gmail dot com Assigned: ab (profile)
Status: Closed Package: Date/time related
PHP Version: 5.5.0alpha5 OS: win 7 (32/64)
Private report: No CVE-ID: None
 [2013-03-06 15:45 UTC] bugzilla77 at gmail dot com
Description:
------------
microtime(true) returns value less than time() (or $_SERVER['REQUEST_TIME'] or 
$_SERVER['REQUEST_TIME_FLOAT'])
up to a DOZEN seconds!!!

live demo: http://pulsmedica.com.pl/microtime.php

win 7 32bit
apache 2.4.3 + php5apache2_4.dll
php 5.5a5 ts


Test script:
---------------
$_SERVER['REQUEST_TIME']: <?=$_SERVER['REQUEST_TIME']?><br/>
$_SERVER['REQUEST_TIME_FLOAT']: <?=$_SERVER['REQUEST_TIME_FLOAT']?><br/>
time(): <?=time()?><br/>
microtime(true): <?=microtime(true)?><br/><br/>
PHP <?=PHP_VERSION?><br/>
created in <?=(microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'])*1000?> ms


Expected result:
----------------
PHP 5.4: never problems


Actual result:
--------------
PHP 5.5 live demo: http://pulsmedica.com.pl/microtime.php


Patches

win32_microtime_var3 (last revision 2013-03-08 14:47 UTC by ab@php.net)
win32_microtime_var1.patch (last revision 2013-03-08 07:56 UTC by ab@php.net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-07 06:56 UTC] pajoye@php.net
@a can you take a look please?
 [2013-03-07 06:56 UTC] pajoye@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: ab
 [2013-03-07 07:45 UTC] bugzilla77 at gmail dot com
The difference is not constant. It grows in proportion to the time since the last 
restart Apache. At the beginning it is a few milliseconds. After a few days up to 
several seconds.
 [2013-03-07 08:12 UTC] ab@php.net
Which apache build are you using? Please try 2.4.4 from here http://www.apachelounge.com/download/additional/ . Also, is the behavior the same in the CLI?
 [2013-03-07 08:35 UTC] bugzilla77 at gmail dot com
I use
Apache 2.4.3 from www.apachelounge.com
or
Apache 2.2.21 from www.apachelounge.com

The problem is only on php 5.5. Php 5.4 no problems.

I will download Apache 2.4.4 from www.apachelounge.com.
But I do not think it's something to help because php 5.4 not affected.
 [2013-03-07 08:38 UTC] bugzilla77 at gmail dot com
...and I use Apache VC10
PHP as php5apache2_4.dll from php package.
 [2013-03-07 08:45 UTC] ab@php.net
Yep, that were my next question :) That's not a good idea to mix CRTs, please use VC11 for both Apache and PHP. You can get a php build for alpha5 here http://windows.php.net/downloads/snaps/php-5.5vc11/php-5.5.0alpha5/ or one of the latest snapshots http://windows.php.net/downloads/snaps/php-5.5/
 [2013-03-07 08:55 UTC] bugzilla77 at gmail dot com
Ok,

I will download: http://www.apachelounge.com/download/win32/binaries/httpd-2.4.4-
win32-VC9.zip

and I will try it with official QA Releases PHP 5.5a5 ts VC9.
 [2013-03-07 09:21 UTC] bugzilla77 at gmail dot com
Ok, I have now installed at home in local machine:

Apache 2.4.4 VC9
http://www.apachelounge.com/download/win32/binaries/httpd-2.4.4-win32-VC9.zip

and as php5apache2_4.dll

PHP 5.5a5 ts VC9
http://windows.php.net/downloads/qa/php-5.5.0alpha5-Win32-VC9-x86.zip


It took about 5 minutes from the restart the server.
created in -10 ms

...and with each page refresh slowly growing.
I think it will be an hour: -100ms
 [2013-03-07 09:27 UTC] bugzilla77 at gmail dot com
It's been 10 minutes from the restart.
created in -52.985191345215 ms

Something is wrong with this PHP 5.5 because 5.4 does not have this problem.
 [2013-03-07 09:28 UTC] ab@php.net
Why VC9? alpha5 is probably the last 5.5 VC9 build. VC11 has however no improvmenent on my side. And how does CLI look on your side?
 [2013-03-07 09:32 UTC] bugzilla77 at gmail dot com
Please wait a moment. Be installing the VC11.
 [2013-03-07 09:41 UTC] ab@php.net
That's what I get in CLI

$_SERVER['REQUEST_TIME']: 1362649203<br/>
$_SERVER['REQUEST_TIME_FLOAT']: 1362649203.6687<br/>
time(): 1362649203<br/>
microtime(true): 1362649203.6699<br/><br/>
PHP 5.5.0-dev<br/>
created in 1.6520023345947 ms

Looks more or less OK. Probably this is an apache specific bug.
 [2013-03-07 09:45 UTC] bugzilla77 at gmail dot com
This may not be a Apache problem because PHP 5.(3|4) has no problem.

Ok, I have now installed at home in local machine:

Apache 2.4.4 VC11
http://www.apachelounge.com/download/win32/binaries/httpd-2.4.4-win32-VC11.zip

and as php5apache2_4.dll

PHP 5.5a5 ts VC11
http://windows.php.net/downloads/snaps/php-5.5vc11/php-5.5.0alpha5/php-
5.5.0alpha5-Win32-VC11-x86.zip


It seems that the problem is resolved.
But to be sure I have to wait a few hours and check on several other machines.

I will describe the results soon.

Is the final PHP 5.5 will be compiled using VC11?
 [2013-03-07 09:58 UTC] bugzilla77 at gmail dot com
Unfortunately excited too quickly.

created in -20.360946655273 ms

As you can see the problem occurs on various compilations Apache and PHP.

But only for PHP 5.5. Not for 5.4.
 [2013-03-07 10:35 UTC] bugzilla77 at gmail dot com
There is no problem on mod_fcgid.so

Only with php5apache2_4.dll and ONLY PHP 5.5.
 [2013-03-08 07:56 UTC] ab@php.net
The following patch has been added/updated:

Patch Name: win32_microtime_var1.patch
Revision:   1362729390
URL:        https://bugs.php.net/patch-display.php?bug=64370&patch=win32_microtime_var1.patch&revision=1362729390
 [2013-03-08 09:10 UTC] ab@php.net
@bugzilla77 I've uploaded a build based on patched sources here   http://windows.php.net/downloads/snaps/ostc/build/64370/ . Ideally you could test ts as apache module and nts as fcgi with apache or iis.
 [2013-03-08 11:27 UTC] bugzilla77 at gmail dot com
I'm testing ts as apache module about half hour and "created in" is always 
positive.

Bug resolved! Many thanks!
Super - I'm waiting for official PHP 5.5 beta 1 ;)

----

With fcgi this problem has never occured.
Checking and it is (as before) ok.
 [2013-03-08 14:47 UTC] ab@php.net
The following patch has been added/updated:

Patch Name: win32_microtime_var3
Revision:   1362754050
URL:        https://bugs.php.net/patch-display.php?bug=64370&patch=win32_microtime_var3&revision=1362754050
 [2013-03-11 15:15 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8aaa09636a3efee7d6e92103dad1ae2c1d137e72
Log: Fixed bug #64370 (microtime(true) less than $_SERVER['REQUEST_TIME_FLOAT'])
 [2013-03-11 15:15 UTC] ab@php.net
-Status: Assigned +Status: Closed
 [2013-03-12 08:10 UTC] ab@php.net
@bugzilla77 could you please try this official snap http://windows.php.net/downloads/snaps/php-5.5/re5c64c0/ . On win8 you might get better accuracy, on win7 and older much predictable results and less randomness.
 [2013-03-12 08:11 UTC] pajoye@php.net
leave it assigned, if tests pass for 5.5, it has to be merged to 5.3 and 5.4.
 [2013-03-12 08:11 UTC] pajoye@php.net
-Status: Closed +Status: Assigned
 [2013-03-12 09:52 UTC] bugzilla77 at gmail dot com
It seems to be OK. Testes on Windows 7, ts, php5apache2_4.dll.
 [2013-03-15 18:19 UTC] ab@php.net
-Status: Assigned +Status: Closed
 [2013-03-15 18:19 UTC] ab@php.net
The latest tests on 5.5 showed no regressions, so merged back into 5.3 and 5.4.
 [2013-11-17 09:31 UTC] laruence@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8aaa09636a3efee7d6e92103dad1ae2c1d137e72
Log: Fixed bug #64370 (microtime(true) less than $_SERVER['REQUEST_TIME_FLOAT'])
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 09:01:32 2024 UTC