Created
May 16, 2012 15:08
-
-
Save lauraxt/2711062 to your computer and use it in GitHub Desktop.
Crash PHP!
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 | |
// origin: https://bugs.php.net/bug.php?id=40479 | |
define('OBJECT_COUNT', 20 * 1000); | |
class Object { | |
private static $world = array(); | |
private static $maxGuid = 0; | |
protected $_guid = null; | |
public function __construct() { | |
self::$world[$this->_guid = self::$maxGuid++] = $this; | |
} | |
public function __destruct() { | |
unset(self::$world[$this->_guid]); | |
} | |
} | |
for ($i = 0; $i < OBJECT_COUNT; ++$i) { | |
new Object(); | |
} | |
// You probably won't see this because of the "zend_mm_heap corrupted" | |
echo 'If you see this, try to increase OBJECT_COUNT to 100,000'; | |
// adding gc_disable stops this from dumping core | |
// remove the following line to produce core dumps | |
gc_disable(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment