SV: [PHP-DEV] PHP 4.0 Bug #3698 Updated: Segfault w/ classes

From: Date: Fri, 03 Mar 2000 14:10:49 +0000
Subject: SV: [PHP-DEV] PHP 4.0 Bug #3698 Updated: Segfault w/ classes
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-16342@lists.php.net to get a copy of this message
Full Bug description available at: http://bugs.php.net/version4/?id=3698 Andi wrote: > This is a tough cookie. We'll look into it. > What makes you write such crashing code? :) The original code consists of 1000's of lines in many files. I reduced it to 10 lines for everybodys' convenience :) The problem is actually that I wrongly assumed that a derived class without a constructor would not call the constructor of its parent class. If I put an empty constructor in the Second_class, the problem disappears. I'm not sure if it's I who is stupid, the documentation that could be a bit clearer, or both. Still, userland code should not be able to crash PHP/Zend even through ignorance and/or stupidity. I'll add a comment explaining the user-side sollution, but I won't close the bug, since there seems to be some heavy wizardry required from the PHP/Zend sourcerers to detect and stop the vile and ignorant programmer from these acts of self-destruction. :) (Good luck.) --- hholzgra wrote: > seems like an "out of memory" problem thats > not caught ad reported in an understandable > way Definitely. > 1) you request a new object of type first_class, > > 2) its constructor requests a new second_class object > > 3) second_class has no constructor of its own, so base_class constructor > is used This is the real problem. I wrongly assumed that base_class constructor would not be used. Putting an empty constructor in second_class makes the problem disappear. > 4) base_class constructor requests a new first_class object > > 5) continue at step 2) until memory is full Regards to everybody involved, /Johan Ekenberg

« previous php.dev (#16342) next »