|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-11-28 18:40 UTC] Jason at AMP-design dot net
Description:
------------
When a interface extends it's self, it will cause PHP to crash when reflective language features such as instanceOf, is_a are used on objects that implement the recursive interface.
Reproduce code:
---------------
<?php
interface RecurisiveFooFar extends RecurisiveFooFar {}
class A implements RecurisiveFooFar {}
$a = new A();
var_dump($a instanceOf A);
?>
Expected result:
----------------
Something like ...
Fatal Error: interface can not extend it's self on line __LINE__ in __FILE__
Actual result:
--------------
PHP Crashes. Apache log shows this activity.
[Sun Nov 28 15:47:43 2004] [notice] Parent: child process exited with status 128 -- Restarting.
[Sun Nov 28 15:47:43 2004] [notice] Parent: Created child process 3932
[Sun Nov 28 15:47:43 2004] [notice] Child 3932: Child process is running
[Sun Nov 28 15:47:43 2004] [notice] Child 3932: Acquired the start mutex.
[Sun Nov 28 15:47:43 2004] [notice] Child 3932: Starting 250 worker threads.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
Reproduced with HEAD too. Please, review the patch below: Index: zend_compile.c =================================================================== RCS file: /repository/ZendEngine2/zend_compile.c,v retrieving revision 1.600 diff -u -r1.600 zend_compile.c --- zend_compile.c 16 Oct 2004 23:17:58 -0000 1.600 +++ zend_compile.c 28 Nov 2004 17:48:34 -0000 @@ -1997,6 +1997,10 @@ if (!(ce->ce_flags & ZEND_ACC_INTERFACE) && iface->interface_gets_implemented && iface->interface_gets_implemented(iface, ce TSRMLS_CC) == FAILURE) { zend_error(E_CORE_ERROR, "Class %s could not implement interface %s", ce->name, iface->name); } + + if (ce == iface) { + zend_error(E_CORE_ERROR, "Interface %s cannot not implement itself", ce->name); + } }