Skip to content

Instantly share code, notes, and snippets.

@xcombelle xcombelle/test.php Secret
Last active Sep 3, 2016

Embed
What would you like to do?
php problem
#!/usr/bin/env php
<?php
class Dangerous {
private $object;
public function __construct()
{
$this->object = new \stdClass();;
}
public function exec() {
echo "dangerous";
}
}
class NotDangerous {
public function exec() {
echo "not dangerous";
}
}
class SegfaultScenario
{
private $circular_reference;
private $object;
public function __construct()
{
$this->circular_reference = $this;
$this->notDangerous = new \NotDangerous();
}
public function __destruct()
{
if (!$this->notDangerous) {
return;
}
$notUsed = new \Dangerous();;
$this->notDangerous->exec();
}
}
new SegfaultScenario();
gc_collect_cycles();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.