From:             wmeler at wp-sa dot pl
Operating system: any
PHP version:      5.3.0
PHP Bug Type:     Scripting Engine problem
Bug description:  serialization adds random references

Description:
------------
Serialization relies on perfect hashing (without collisions) of variables
in ext/standard/var.c - php_add_var_hash. Collision result in random
reference to previously serialized variable. 
It is possible to happen because hash function used for objects is not
perfect one - for two objects of different classes it is possible to get
the same hash result.
I've just fixed the same problem in 4.x where collisions were more
frequent because of use of HANDLE_NUMERIC in zend_hash_add and
zend_hash_next_index_insert.
Problem is extremely hard to reproduce and debug because of pointer value
sensitivity, while easy to fix. Instead of single
smart_str_print_long(hash) we could use concatenation - two calls -
smart_str_print_long(Z_OBJCE_P(var);smart_str_print_long(Z_OBJ_HANDLE_P(var))
- or even faster version with binary memcpy of two pointers without 'O'
prefix. If you wan't to I can provide this simple patch for 5.3.0.


-- 
Edit bug report at http://bugs.php.net/?id=49374&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=49374&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=49374&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=49374&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=49374&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=49374&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=49374&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=49374&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=49374&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=49374&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=49374&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=49374&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=49374&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=49374&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=49374&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=49374&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=49374&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=49374&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=49374&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=49374&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=49374&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=49374&r=mysqlcfg

Reply via email to