|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58796 Int32 overflow in i386 machines while displaying the profiler results
Submitted: 2009-08-07 15:54 UTC Modified: 2017-10-24 08:23 UTC
Avg. Score:4.2 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:3 (75.0%)
From: dmitry dot koterov at gmail dot com Assigned:
Status: Suspended Package: xhprof (PECL)
PHP Version: 5_2 CVS-2009-08-07 (dev) OS: all
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:
33 + 19 = ?
Subscribe to this entry?

 [2009-08-07 15:54 UTC] dmitry dot koterov at gmail dot com
Sometimes on i386 machines (not x86_64) xhprof displays wrong values in "Excl. Wall Time" column - extremely high (near 2 billions). Seems we have int32 overflow here while calculating.

The patch is attached. It simply converts all microseconds to double. It forces PHP to automatically cast to double all expression which use these values. It avoids overflows while displaying and calculating the statistics. I'll be pleased if you apply this patch in a next version.

Index: xhprof_lib/utils/xhprof_runs.php
--- xhprof_lib/utils/xhprof_runs.php	(revision 14556)
+++ xhprof_lib/utils/xhprof_runs.php	(working copy)
@@ -118,7 +118,15 @@
     $contents = file_get_contents($file_name);
     $run_desc = "XHProf Run (Namespace=$type)";
-    return unserialize($contents);
+    $dump = unserialize($contents);
+    // Convert all numbers to float to avoid int32 overflow.
+    foreach ($dump as $k => $v) {
+      $dump[$k]['ct'] = floatval($dump[$k]['ct']); 
+      $dump[$k]['wt'] = floatval($dump[$k]['wt']); 
+    }
+    return $dump;
   public function save_run($xhprof_data, $type, $run_id = null) {


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-07 15:56 UTC] dmitry dot koterov at gmail dot com
The subject of this issue is corrected.
 [2009-08-07 16:24 UTC] dmitry dot koterov at gmail dot com
Oh! Seems the problem is not only an integer overflow. Sometimes profiling dump looks like:

   [a==>b] => Array
            [ct] => 1
            [wt] => -2147483648

Note the negative [wt] value above! Reproducing is not stable: sometimes it works OK, sometimes not.

And seems this effect is reproduced more often if xdebug is also active together xhprod. If xdebug is turned off, no negative values are present, but sometimes wt=0 for all rows.

So, possibly this is an xdebug side-effect in most cases...
 [2012-06-12 18:02 UTC]
-Assigned To: +Assigned To: scottmac
 [2017-10-24 06:13 UTC]
-Status: Assigned +Status: Open -Assigned To: scottmac +Assigned To:
 [2017-10-24 08:23 UTC]
-Status: Open +Status: Suspended
 [2017-10-24 08:23 UTC]
This package has not had a release for over 4 years, and the last bit of git activity was over 2 years ago, so I think its safe to say this extension is no longer in active development. If development picks back up, then please re-open this report
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 01 10:01:28 2024 UTC