|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74479 usleep with large numbers
Submitted: 2017-04-20 14:32 UTC Modified: -
Avg. Score:2.0 ± 1.0
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: korchasa at gmail dot com Assigned:
Status: Open Package: Unknown/Other Function
PHP Version: 5.6.30 OS: Ubuntu 16.04.2 with 4.8.0-46
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
38 - 18 = ?
Subscribe to this entry?

 [2017-04-20 14:32 UTC] korchasa at gmail dot com
usleep works strange on large numbers

Test script:
$start = microtime(true);
usleep(4294967296 + 1000000);
echo round(microtime(true) - $start);

Expected result:
12h pause and 4296 in output or error message

Actual result:
1 second pause and 1 in output


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-20 15:00 UTC]
This is a 32-bit integer overflow issue, it will happen regardless of platform because there is an explicit (unsigned int) cast when the underlying usleep(3) is called.

I would argue that you shouldn't use usleep() to sleep for that kind of time anyway - if you are sleeping for 12 hours, sub-second precision doesn't really matter and is not reasonable to expect.

However in 64-bit environments the expected behaviour could be emulated.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jan 27 02:01:24 2020 UTC