From:             arjen at react dot com
Operating system: Linux
PHP version:      5.4Git-2013-08-30 (Git)
Package:          Reproducible crash
Bug Type:         Bug
Bug description:Segfault when calling parent::serialize in serialize().

Description:
------------
>From https://bugs.php.net/bug.php?id=63481&edit=3
Created new issue cause it's different from original bugreport.

See 
https://gist.github.com/aurelijus/4713758

Crashes 5.4.0 - 5.5.3: http://3v4l.org/PBT99

Test script:
---------------
<?php
class Permission implements \Serializable {
    protected $id = 3;
    public function serialize()
    {
        return serialize(array($this->id));
    }
    public function unserialize($serialized)
    {
        list($this->id) = unserialize($serialized);
    }
 
}
 
class UserPermission implements \Serializable {
    public $permission;
    public $webshop;
 
    public function serialize()
    {
        return serialize(array($this->webshop, $this->permission));
    }
    public function unserialize($serialized)
    {
        list($this->webshop, $this->permission) =
unserialize($serialized);
    }
}
 
class Webshop  implements \Serializable {
    protected $id = 13;
    public function serialize()
    {
        return serialize(array($this->id));
    }
    public function unserialize($serialized)
    {
        list($this->id) = unserialize($serialized);
    }
 
}
 
class AbstractToken  implements \Serializable {
    public $roles;
 
    public function serialize()
    {
        return serialize(array($this->roles));
    }
    public function unserialize($serialized)
    {
        list($this->roles) = unserialize($serialized);
    }
 
}
class UsernamePasswordToken extends AbstractToken {
    private $credentials = null;
    private $providerKey = null;
 
    public function serialize()
    {
        return serialize(array($this->credentials, $this->providerKey,
parent::serialize()));
    }
 
    public function unserialize($str)
    {
        list($this->credentials, $this->providerKey, $parentStr) =
unserialize($str);
        parent::unserialize($parentStr);
    }
}
 
$token = new UsernamePasswordToken();
$webshop = new Webshop;
$permission = new Permission;
$roles = array();
for ($i = 0; $i < 2; $i++) {
    $roles[$i] = new UserPermission();
    $roles[$i]->webshop = $webshop;
    $roles[$i]->permission = $permission;
}
$token->roles = $roles;
var_dump(unserialize(serialize($token)));

Actual result:
--------------
segfault
Backtrace @ https://gist.github.com/anonymous/5720464

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

Reply via email to