Created
September 5, 2013 00:33
-
-
Save AlekseyKorzun/6444589 to your computer and use it in GitHub Desktop.
Proof of concept, segmentation fault (spl_array.c/igbinary.c) when using nested objects.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Proof of concept, segmentation fault (spl_array.c/igbinary.c) | |
* when using nested objects. | |
* | |
* PHP 5.3.6, PECL-Memcached 1.x, Igbinary 1.x | |
* | |
* @author Aleksey Korzun | |
*/ | |
/** | |
* You must have pecl-memcached + igbinary | |
*/ | |
DEFINE('MEMCACHE_SERVER', '192.168.2.85'); | |
DEFINE('MEMCACHE_PORT', 11211); | |
class Object | |
{ | |
} | |
class Storage | |
{ | |
public $storage; | |
public function __construct() | |
{ | |
$this->storage = new Object(); | |
} | |
} | |
class Collection extends \ArrayObject | |
{ | |
CONST LIMIT = 1000; | |
public function populate() | |
{ | |
$limit = 0; | |
while ($limit) { | |
append(new Storage); | |
} | |
++$limit; | |
} | |
} | |
$memcached = new Memcached; | |
$memcached->setOption( | |
$memcached::OPT_SERIALIZER, | |
$memcached::SERIALIZER_IGBINARY | |
); | |
$memcached->addServer(MEMCACHE_SERVER, MEMCACHE_PORT); | |
$collection = new Collection; | |
$collection->populate(); | |
if ($memcached->set('foobar', $collection, 10)) { | |
if ($memcached->get('foobar')) { | |
print "Passed"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment