ID: 32799 Updated by: [EMAIL PROTECTED] Reported By: rd dot contact at free dot fr -Status: Open +Status: Verified -Bug Type: Reproducible crash +Bug Type: Zend Engine 2 problem Operating System: * PHP Version: 5CVS-2005-04-25
Previous Comments: ------------------------------------------------------------------------ [2005-04-22 19:34:46] rd dot contact at free dot fr /* -- TEST 1 I use the global var instead of "$this" to demonstrate that calling it will segfault php. Try TEST2 to see why it could be useful to use the global var during the destruct. unset($p) instead of $p=[anything], don't crash. */ class test{ public $c=1; function __destruct (){ $GLOBALS['p']->c++; // no warning print $GLOBALS['p']->c; // segfault } } $p=new test; $p=null; //destroy the object by a new assignment (segfault) //---CUT---- /* -- TEST 2 More realistic example: During the destruct, I need to call an external function that uses the global var of the object. calling a methode: works incrementing a property: segfault */ function dbug($msg){ $GLOBALS['p']->printmsg($msg); // works $GLOBALS['p']->c++; // segfault } class test{ public $c=1; function __destruct (){dbug('Destruct');} function printmsg($msg){print $msg;} } $p=new test; $p=null; //destroy the object by a new assignment (segfault) ------------------------------------------------------------------------ [2005-04-22 14:31:18] [EMAIL PROTECTED] Can you give a bit more realistic example script? The one here does not make any sense.. ------------------------------------------------------------------------ [2005-04-22 05:19:51] rd dot contact at free dot fr Description: ------------ During the __destruct, when using the global var assigned to the object, php crashes in some cases. Reproduce code: --------------- class test{ function __destruct (){ //$GLOBALS['p']=$this; // <- this crash apache for all tests //$GLOBALS['p']++; // <- this crash apache for all tests print_r($GLOBALS['p']); // <- crash only test 1. test 2 => "Undefined variable p" } } $p=new test; //test 1 $p=1; // crash apache (as $p=null, $p='bug', $p=new test ...) //but, //test 2 //unset($p); // no crash: "Undefined variable: p on line 5" Expected result: ---------------- No crash, and a way to use the global var during destruct. (so destruct could call external functions that use the global var of the object. Why not unregister the global var after the destruct call ?) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32799&edit=1