Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@AlekseyKorzun
Created September 5, 2013 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlekseyKorzun/6444589 to your computer and use it in GitHub Desktop.
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.
<?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