Skip to content

Instantly share code, notes, and snippets.

@TrafeX
Last active December 17, 2015 22:39
Show Gist options
  • Save TrafeX/5683430 to your computer and use it in GitHub Desktop.
Save TrafeX/5683430 to your computer and use it in GitHub Desktop.
This causes a segmentation fault in PHP 5.4.11
<?php
class example
{
private $instance;
public function getInstance()
{
// Lazy load the instance
if (null === $this->instance) {
$this->instance = new example();
}
return $this->instance;
}
public function test()
{
// This creates a loop
$this->getInstance()->test();
}
}
$c = new Example();
$c->test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment