Bug #69693 [Com]: Reproducible Corruption on Variables
| From: | bugs at tmarques dot com | Date: | Sat, 23 May 2015 00:36:49 +0000 |
| Subject: | Bug #69693 [Com]: Reproducible Corruption on Variables | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-192836@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69693&edit=1
ID: 69693
Comment by: bugs at tmarques dot com
Reported by: bugs at tmarques dot com
Summary: Reproducible Corruption on Variables
Status: Feedback
Type: Bug
Package: *General Issues
Operating System: Linux x32
PHP Version: 5.5.25
Block user comment: N
Private report: N
New Comment:
Sure, it's small values. Real code was $i=68 and $l=71, IIRC. You can see the test case on the
Gist I posted in the description on the bug. There it returns a float with smaller integers. What
should have been 10 or so becomes 9.xx*10^18, something like that.
As I mentioned, all code runs fine in i686 but "blows up" on x32 ABI (which is quite
useful no virtualized servers).
Previous Comments:
------------------------------------------------------------------------
[2015-05-22 22:30:34] danack@php.net
"two variables that have integers get summed and return a float."
Yes - this is the defined behaviour for when an operation occurs and the result is no longer
representable as an integer type. e.g.
<?php
$x = PHP_INT_MAX;
$x += 1;
var_dump($x);
?>
Will say that $x is a float value. Or to quote from the manual - http://php.net/manual/en/language.types.integer.php
"If PHP encounters a number beyond the bounds of the integer type, it will be interpreted as a
float instead. Also, an operation which results in a number beyond the bounds of the integer type
will return a float instead."
If you think the conversion from int to float is occurring inappropriately, please can you provide a
simple reproduction case?
------------------------------------------------------------------------
[2015-05-22 18:47:44] bugs at tmarques dot com
P.S. I would look into this further but have no idea where to look for the problem or how to debug
PHP internal's. Looking for some input and happy to help with testing in any way I can.
------------------------------------------------------------------------
[2015-05-22 18:39:05] bugs at tmarques dot com
Description:
------------
This is a bug I ran into when using Wordpress normally. After running a script for a while on a x32
ABI php, it enters an infinite loop that exhausts process memory. Upon investigation, two variables
that have integers get summed and return a float. Depending on the input text, the loop doesn't
trigger the bug.
This doesn't happen on i386/i686, haven't tested on x86-64.
Test script:
---------------
Please see both examples at:
https://gist.github.com/anonymous/4320f460cd1e4144df2a
Relevant code is "run.php" from lines 96 to 120.
It never triggers if I copy the $text variable to another one that's not even used ($_test).
It also returns the correct sum for a test in the code as:
if ( is_float( $i + $l ) === TRUE )
So I have to sum and check if the value is big (it usually returns some float of E+18 magnitude).
Expected result:
----------------
Integer variables sum and result in an integer.
Actual result:
--------------
Sum of two integers returns a float.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69693&edit=1