-
-
Save xcombelle/cc8c391e93d01dfe9568bf634a656767 to your computer and use it in GitHub Desktop.
php problem
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
#!/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