php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32213 Array key serialize problem 64 bit php
Submitted: 2005-03-07 03:45 UTC Modified: 2005-04-04 06:45 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: csmith at cbbc dot murdoch dot edu dot au Assigned: helly (profile)
Status: Closed Package: Session related
PHP Version: * OS: 64 bit versions
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 !
Your email address:
MUST BE VALID
Solve the problem:
32 + 44 = ?
Subscribe to this entry?

 
 [2005-03-07 03:45 UTC] csmith at cbbc dot murdoch dot edu dot au
Description:
------------
Having this bug in 64 bit versions of php only. 32 bit versions work as expected.

If you create an array with large integers as the keys, serialize the array, and unserialize the array, (so you can pass it through a session) the array key value is not being type promoted to a data type that can store the large integer. 

Instead you get a different value back as the key after unserializing the array. 

This is happening with the 64 bit versions of 5.0.3 and  4.3.2.

Reproduce code:
---------------
$array["1234567891011"] = 'test';
print "The array:<br/>";
var_dump( $array);
$array_serialized = serialize($array);

$array_unserialized = unserialize($array_serialized);
print "<br/>The unserialized array:<br/>";
var_dump($array_unserialized);



Expected result:
----------------
The array:
array(1) { [1234567891011]=> string(4) "test" }
The unserialized array:
array(1) { [1234567891011]=> string(4) "test" } 


*Note: this is what you get back in the 32 bit version of php.

Actual result:
--------------
The array:
array(1) { [1234567891011]=> string(4) "test" }
The unserialized array:
array(1) { [1912277059]=> string(4) "test" } 


*Note: this is what you get back in the 64 bit version of php.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-07 20:09 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-03-08 07:33 UTC] csmith at cbbc dot murdoch dot edu dot au
Ok. Tried to compile the latest version from cvs for a AMD Opteron (64 bit server) running lunix.

It wouldn't compile. Seems to have a problem with var_unserializer :
 

/bin/sh /root/software/php5-200503080330/libtool --silent  --preserve-dup-deps --mode=compile gcc  -Iext/standard/  -I/root/software/php5-200503080330/ext/standard/ -DPHP_ATOM_INC  -I/root/software/php5-200503080330/include  -I/root/software/php5-200503080330/main  -I/root/software/php5-200503080330  -I/root/software/php5-200503080330/Zend -I/usr/include/libxml2  -I/usr/local/include  -I/root/software/php5-200503080330/TSRM  -g -O2    -c /root/software/php5-200503080330/ext/standard/var_unserializer.c -o  ext/standard/var_unserializer.lo

/root/software/php5-200503080330/ext/standard/var_unserializer.c: In  function `object_custom':
/root/software/php5-200503080330/ext/standard/var_unserializer.c:296:  warning: passing arg 2 of pointer to function from incompatible pointer  type
/root/software/php5-200503080330/ext/standard/var_unserializer.c:296:  warning: passing arg 3 of pointer to function makes pointer from  integer without a cast
/root/software/php5-200503080330/ext/standard/var_unserializer.c:296:  warning: passing arg 4 of pointer to function makes integer from  pointer without a cast
/root/software/php5-200503080330/ext/standard/var_unserializer.c:296:  too few arguments to function
make: *** [ext/standard/var_unserializer.lo] Error 1
 [2005-03-09 00:52 UTC] sniper@php.net
Please get the latest snapshot again as this might have been fixed already. If it isn't, paste the offending line here.

 [2005-03-09 10:45 UTC] csmith at cbbc dot murdoch dot edu dot au
Snapshot: php5-200503090330
Compiled: for Apache 2.0.53 

Compiles ok, but original bug is still occuring.
 [2005-04-04 06:45 UTC] csmith at cbbc dot murdoch dot edu dot au
Fixed in CVS.
 
Duplicate of bug #31442 http://bugs.php.net/bug.php?id=31442

Using patch in bug report 31442 to patch php 5.0.3
 
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Feb 08 05:05:48 2023 UTC