php.net |  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
Votes:4
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dmitry dot koterov at gmail dot com
New email:
PHP Version: OS:

 

 [2009-08-07 15:54 UTC] dmitry dot koterov at gmail dot com
Description:
------------
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) {



Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

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] sixd@php.net
-Assigned To: +Assigned To: scottmac
 [2017-10-24 06:13 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: scottmac +Assigned To:
 [2017-10-24 08:23 UTC] kalle@php.net
-Status: Open +Status: Suspended
 [2017-10-24 08:23 UTC] kalle@php.net
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-2019 The PHP Group
All rights reserved.
Last updated: Mon Dec 16 12:01:23 2019 UTC