From: joe at popcast dot com Operating system: linux, XP, Mac PHP version: 5.0.5 PHP Bug Type: Reproducible crash Bug description: here's how to seg fault php everytime by doing simple OOP
Description: ------------ Using PHP from the standard Windows installer and running under Apache, the following code both produces unexpected output and crashes PHP. The code is a simple OOP variable test. A similar bug was posted (http://bugs.php.net/bug.php?id=26930) but did not crash PHP. To reproduce the crash, uncomment the test method in class B or C and seg fault away. The bug is reproducible on every OS I've tested, including Linux and Mac with standard PHP installs running under Apache. Reproduce code: --------------- class A { protected static $instance; public $test = "A"; public function getInstance() { if (! self::$instance) self::$instance = new A; return self::$instance; } public function test() { echo $this->test; } } class B extends A { protected static $instance; //protected $test = "B"; public function getInstance() { if (! self::$instance) self::$instance = new B; self::$instance->test = "B"; return self::$instance; } /* public function test() { echo $this->test(); } */ } class C extends A { protected static $instance; //protected $test = "C"; public function getInstance() { if (! self::$instance) self::$instance = new C; self::$instance->test = "C"; return self::$instance; } /* public function test() { echo $this->test(); } */ } $a = new A; $a->test(); echo "\n----------<br>\n"; $b = new B; $a->test(); $b->test(); echo "\n----------<br>\n"; $c = new C; $a->test(); $b->test(); $c->test(); echo "\n----------<br>\n"; Expected result: ---------------- A ---------- AB ---------- ABC ---------- Actual result: -------------- A ---------- AA ---------- AAA ---------- -- Edit bug report at http://bugs.php.net/?id=35123&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=35123&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=35123&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=35123&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=35123&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=35123&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=35123&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=35123&r=needscript Try newer version: http://bugs.php.net/fix.php?id=35123&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=35123&r=support Expected behavior: http://bugs.php.net/fix.php?id=35123&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=35123&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=35123&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=35123&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35123&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=35123&r=dst IIS Stability: http://bugs.php.net/fix.php?id=35123&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=35123&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=35123&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=35123&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=35123&r=mysqlcfg