From: max at phoenixweb dot it
Operating system: Centos 5.2 x86 64bit
PHP version: 5.2.8
PHP Bug Type: Variables related
Bug description: Serialize / Unserialize missbehaviour under OS with different
bit numbers
Description:
------------
The problem is easy.
I use SERIALIZE - UNSERIALIZE to pass complex PHP objects between server e
store it on remote.
However the SERIALIZE - UNSERIALIZE process fail while this happens
between a 64bit OS and a 32bit OS, due to a missbehaviour in the number
rappresentation (int).
For the 64bit the (INT) is the correct data type for the number:
4139868160 while for a 32bit system that numbero can handled only by a
(DOUBLE)
s:3:"mem";a:2:{s:6:"memory";a:5:{s:5:"total";i:4139868160;s:4:"free";i:1306845184;s:7:"buffers";i:74797056;s:6:"cached";i:2103566336;s:4:"used";i:2833022976;}s:4:"swap";a:3:{s:5:"total";i:8389742592;s:4:"free";i:8389742592;s:4:"used";i:0;}}
During the UNSERIALIZE function on the 32bit system the bitcode is lost
and the number became negative.
Reproduce code:
---------------
serialize this object on different OS:
[mem] => Array
(
[memory] => Array
(
[total] => 4139868160
[free] => 1331732480
[buffers] => 68988928
[cached] => 2102939648
[used] => 2808135680
)
[swap] => Array
(
[total] => 8389742592
[free] => 8389742592
[used] => 0
)
)
you'll get different SERIALIZED string that are not OS indipendent.
Expected result:
----------------
I expected that the object could be pass throug PHP servers indipendently
from the OS bit system.
Actual result:
--------------
The actual result is a serialized string not indipendent from OS, i think
i'll use JSON functions instead of serialize / unserialize.
--
Edit bug report at http://bugs.php.net/?id=46882&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=46882&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=46882&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=46882&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=46882&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=46882&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=46882&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=46882&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=46882&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=46882&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=46882&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=46882&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=46882&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=46882&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=46882&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46882&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46882&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=46882&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=46882&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=46882&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=46882&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=46882&r=mysqlcfg