Edit report at https://bugs.php.net/bug.php?id=64633&edit=1

 ID:                 64633
 Updated by:         yohg...@php.net
 Reported by:        phpbugs at musiclogistics dot net
 Summary:            microtime regression - resolution reduced to 64
                     ticks per second
 Status:             Assigned
 Type:               Bug
 Package:            Date/time related
 Operating System:   Windows 7
 PHP Version:        5.4.14
 Assigned To:        pajoye
 Block user comment: N
 Private report:     N

 New Comment:

Anyone could verify that this wouldn't happen with Windows 8/Windows Server 
2012?
It seems different API is used for these platforms.


Previous Comments:
------------------------------------------------------------------------
[2013-08-01 06:07:53] yohg...@php.net

I guess this commit is the cause.

git show  b022e54bd100a914417e216
commit b022e54bd100a914417e216d0872d3e67edecaf9
Author: Anatol Belski <a...@php.net>
Date:   Sat Mar 23 17:40:06 2013 +0100

    Fixed possible precision loss in microtime
    
    This is related to the fix for bug #64370. MSVC natively supports __int64 
type,
    so calculating with 32 bit ints is neither necessary nor reliable. Therefore
    an older piece of code is reused.

diff --git a/win32/time.c b/win32/time.c
index 77e4504..7553974 100644
--- a/win32/time.c
+++ b/win32/time.c
@@ -50,6 +50,7 @@ int getfilesystemtime(struct timeval *tv)
        FILETIME ft;
        unsigned __int64 ff = 0;
        MyGetSystemTimeAsFileTime timefunc;
+       ULARGE_INTEGER fft;
 
        timefunc = get_time_func();
        if (timefunc) {
@@ -58,14 +59,20 @@ int getfilesystemtime(struct timeval *tv)
                GetSystemTimeAsFileTime(&ft);
        }
 
-       ff |= ft.dwHighDateTime;
-       ff <<= 32;
-       ff |= ft.dwLowDateTime;
-       ff /= 10; /* convert to microseconds */
+        /*
+        * Do not cast a pointer to a FILETIME structure to either a 
+        * ULARGE_INTEGER* or __int64* value because it can cause alignment 
faults on 64-bit Windows.
+        * via  http://technet.microsoft.com/en-
us/library/ms724284(v=vs.85).aspx
+        */
+       fft.HighPart = ft.dwHighDateTime;
+       fft.LowPart = ft.dwLowDateTime;
+       ff = fft.QuadPart;
+
+       ff /= 10Ui64; /* convert to microseconds */
        ff -= 11644473600000000Ui64; /* convert to unix epoch */
 
-       tv->tv_sec = (long)(ff / 1000000UL);
-       tv->tv_usec = (long)(ff % 1000000UL);
+       tv->tv_sec = (long)(ff / 1000000Ui64);
+       tv->tv_usec = (long)(ff % 1000000Ui64);
 
        return 0;
 }

------------------------------------------------------------------------
[2013-08-01 05:43:03] yohg...@php.net

Just a note.
Linux does not have problem at all, it seems.

http://3v4l.org/nMBha

------------------------------------------------------------------------
[2013-08-01 05:04:57] yaro2000 at yandex dot ru

5.4.09 - OK, 5.4.10 - OK ... 5.4.14 - BUG, 5.4.15 - BUG
Why?

------------------------------------------------------------------------
[2013-07-31 07:19:11] martin dot hason at gmail dot com

The same problem occurs in PHP 5.5.1 too! Please fix this bug.

------------------------------------------------------------------------
[2013-06-16 04:02:52] yaro at opti dot su

The same problem occurs in PHP 5.4.15 too!
Why developers ignore such an important issue?

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=64633


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64633&edit=1

Reply via email to