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: 2012-06-12 18:02 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: dmitry dot koterov at gmail dot com Assigned: scottmac
Status: Assigned Package: xhprof (PECL)
PHP Version: 5_2 CVS-2009-08-07 (dev) OS: all
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

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
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 24 19:01:53 2014 UTC